I am trying to send some data from my php to a rest service. It seems to make a call correctly to the API but doesnt send any post data.
The Code is :
<?php
$name="abcd";
$id="xyz";
$service_url = 'service/url';
$curl = curl_init($service_url);
$curl_post_data = array(
$name,$id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
curl_close($curl);
?>
I would also like to manipulate the response provided.Can someone tell what i am doing wrong here.
There is a server side validation, The code is :
private String validateAndGetClientName(HttpServletRequest request) throws InvalidRequestException {
String clientName = request.getParameter("name");
if (isEmpty(clientName)) {
throw new InvalidRequestException("Client Name cannot be empty.");
}
return clientName.trim();
}