I’m trying to get a list of contacts last modified after a specified time, but I can’t seem to get it right. When I execute the script, I get the error:
Invalid input JSON on line 1, column 17: Cannot deserialize value of type java.util.HashSetfrom Object value (tokenJsonToken.START_OBJECT)
When I test the post data, it returns as valid JSON:
{"filterGroups":{"filters":{"value":1646144686,"propertyName":"lastmodifieddate","operator":"GT"}}}
I’ve found a few posts both here and on Stack with similar errors, but no solutions.
My code is as such:
$url = "https://api.hubapi.com/crm/v3/objects/contacts/search";
$api_key = 'xxxxxxxxxxxxxxxxxxxxx';
$range = strtotime("-1 hour");
$data = array(
"filterGroups" => array(
"filters" => array(
"value" => $range,
"propertyName" => "lastmodifieddate",
"operator" => "GT"
)
)
);
$post = json_encode($data);
$ch = curl_init($url . "?hapikey=" . $api_key);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response));
Any help with what I’m doing wrong would be greatly appreciated.