i'm trying to send some data to my api with PHP OAuth Library (https://www.phpclasses.org/package/7700-PHP-Authorize-and-access-APIs-using-OAuth.html) but every time an error occurs
Error: it was not possible to access the API call: it was returned an unexpected response status 400 Response: {"message":"Error converting value \"{\"lastName\":\"Smith\",\"firstName\":\"John\",\"webAddresses\":{\"value\":\"[email protected]\"},\"phoneNumbers\":{\"value\":\"0666864\"}}\" to type...
This is my code:
$params = array(
'x-api-key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type' => 'application/json',
'Accept' => 'application/json'
);
$fields = array(
"lastName" => $entries[$tmp_id]["2.6"],
"firstName" => $entries[$tmp_id]["2.3"],
"webAddresses" => array([
"value" => $entries[$tmp_id]["4"]
]),
"phoneNumbers" => array([
"value" => $entries[$tmp_id]["5"]
])
);
$json = json_encode($fields);
$success = $client->CallAPI(
'https://myurl.com/v2/api',
'POST', $json, array('FailOnAccessError'=>true, 'RequestHeaders' => $params,'RequestContentType' => 'application/json', 'FollowRedirection' => true, ), $user);
Any ideas what am i doing wrong? Regards