Another Input could not be converted to a valid request

Hello,

I’m trying to insert a contact via CURL.
I’ve got a returned message : Input could not be converted to a valid request

$nom_fichier_log =“log_infusionsoft_”.date(“Ymd”).“_”.date(“His”).“.txt”;
$fp_log=fopen($nom_fichier_log,“w”);
$data = array(“duplicate_option” => “Email”, “email_adresses” => array(array(“email”=>“test@test.fr”,“field”=>“EMAIL1”)));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.infusionsoft.com/crm/rest/v1/contacts?access_token=xxxxxx”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
“content-type:application/json;charset=UTF-8”,
“Accept:application/json, /
));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$responsecode = $info[‘http_code’];
$final_result = json_decode($result, TRUE);
fwrite($fp_log, “Résultat : “.print_r($final_result, true).”\n”);
fclose($fp_log);

I’ve looked at the other messages. I checked double quotes.

When I add : $parameters = json_encode($data, true); and so send $parameters in CURL_POSTFIELDS
I have this message : Unrecognized property: duplicate_option

What am I missing ?
Best Regards

bumping to top due to accidental spam flag

Restart with the sample json. That error message means that, while modifying the json, it was corrupted in it’s format somehow. Make small changes until you get the message again so you can determine where it went wrong.

Hello,

I’ve waited more help. I 've sent this message beacause I’ve tried several and sevral times, looked at many messages on Internet.

Best Regards

Your cURL call must contain JSON data and you’re trying to pass an array in $data which won’t work. Follow the formats in documentation and you should be ok

https://developer.infusionsoft.com/docs/rest/#!/Contact/createContactUsingPOST