I’ve been attempting to use the HubSpot V3 API PHP library created by HubSpot off gitHub, to add a note to a contact record (I’ve already been able to add a contact successfully).
However, I’m getting a “VALIDATION ERROR” for the “hs_timestamp” required parameter.
I’ve read just about all the posts I could find, and the HubSpot docs, about the UTC or UNIX milliseconds datetime variations that need to be sumbmitted to any datetime field in the API.
However, I still get the same validation error - so I’m stumped.
Here’s the basic code I’ve tried:
### CODE ###
//UTC Time
$dateTime = new DateTime();
$dateTime->setTimeZone(new DateTimeZone(‘America/Chicago’));
$timeStamp = $dateTime->format(“Y-m-d\TH:i:s\Z”);
echo “<br>”;
echo “<br>”;
print_r($timeStamp);
//END - UTC Time
//Milliseconds Time
$timeStamp = $dateTime->getTimestamp()*1000;
//END - Milliseconds Time
$noteProperties = [
“hs_timestamp” => $timeStamp,
“hs_note_body” => “This is a test note…”,
“hubspot_owner_id” => $ownerID
];
$noteObject = new SimplePublicObjectInput([‘properties’ => $noteProperties]);
try
{
$createNote = $hubClient->crm()->objects()->notes()->basicApi()->create($noteObject);
echo “<br>”;
echo “<br>”;
var_dump($createNote);
}
catch (HubSpot\Client\Crm\Objects\Notes\ApiException $e)
{
echo "Exception for basicApi-create(note) ", $e->getResponseBody();
}
### END CODE ###
I’ve also tried quoting my timeStamp variable in the ‘properties’ array when doing the millisecond method in case the API wanted a string and not an integer - same error.
The noteObject I’m passing into the simple input object echo-out looks like this:
noteObject: { “properties”: { “hs_timestamp”: “2022-08-06T20:20:21Z”, “hs_note_body”: “This is a test note…”, “hubspot_owner_id”: 209559322 } }
Any ideas, as to what I’m doing wrong, am I using the library wrong?
Thanks,
Charles