I'm trying to create new contact with custom fields using GetResponse API, here is my code:
$headers = [
'Accept: application/json',
'Content-Type: application/json',
'X-Auth-Token: api-key '.$model->getresponse_key
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, 'https://api.getresponse.com/v3/contacts');
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode([ 'name' => $user->full_name, 'email' => $user->email, 'campaign' => [ 'campaignId' => $model->getresponse_campaign ] , 'customFieldValues' => [['customFieldId' => 'tel', 'value' => [$user->phone]]]], JSON_FORCE_OBJECT));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($curl);
$result2 = json_decode($result);
I'm getting this response:
object(stdClass)#174 (7) {
["httpStatus"]=>
int(400)
["code"]=>
int(1000)
["codeDescription"]=>
string(78) "General error of validation process, more details should be in context section"
["message"]=>
string(34) "Custom field by id: tel not found "
["moreInfo"]=>
string(49) "https://apidocs.getresponse.com/en/v3/errors/1000"
["context"]=>
array(0) {
}
["uuid"]=>
string(36) "b5a2465b-08df-4cdd-80c8-**********"
}
I really don't know what possibly can go wrong in that code, please help.