I doing a post curl request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers = ["Content-Type:application/json","Accept:application/json"];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
return $result;
The above curl request should return a json formated string but getting a string in javascript object form.
string(68) "{data:{errorCode:AC01,errorMessage:SansID 53563857 is exist.}}"
Where as when i try to do the same thing from post man api is returning perfect json.
{"data":{"errorCode":"AC01","errorMessage":"SansID 53563857 is exist."}}
Please let me know where i'm doing wrong.