I am trying to send data via curl by POST.
Here's what I have done
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://lc-api.sdl.com/translate");
$headers = array();
$headers[] = 'Content-type:application/json';
$headers[] = 'Authorization:LC apiKey=QidCWRGQ%2BHsdzGE6rrBgiw%3D%3D';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,"text=Bonjour&from=fra&to=eng"); //Post Fields
$server_output = curl_exec ($ch);
curl_close ($ch);
print $server_output ;
I get an error indicating
Error parsing json at column:6 line:1 offset:-1
Here is the working Curl request
curl -X POST -H "Content-type: application/json" -H "Authorization: LC apiKey=QidCWRGQ%2BHsdzGE6rrBgiw%3D%3D" -d '{"text":"Bonjour", "from" : "fra", "to" : "eng"}' https://lc-api.sdl.com/translate