V3 API - Adding Note: hs_timestamp VALIDATION ERROR
SOLVE
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]);
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?
V3 API - Adding Note: hs_timestamp VALIDATION ERROR
SOLVE
After some other API calls to the provided HubSpot library being "noisy" when my script was placed on a webserver and caused it to return information and freeze the rest of the script, I elected to abandon all usage of the HubSpot library and just use CURL for all my calls.
In the case of my above post about adding a note and the "hs_timestamp" validation issue, I thought I would post my basic code that I used to execute adding a note and associating a note successfully using CURL.
Be advised that while testing many "test notes" may get created and if you don't associate them they kind of sit on your app, you can use the API references "endpoint" sections to do "test posts" to list all notes, and then use all the ID's to delete the ones you don't want etc. Of course if you use a development account this isn't really an issue - I used an production account that isn't in use yet.
So on to the code...some of it is abbreviated, ommitted or changed, in favor of simplicity or privacy:
### Create The Note Code ###
//Get the current time in millliseconds for 'hs_timestamp'
V3 API - Adding Note: hs_timestamp VALIDATION ERROR
SOLVE
After some other API calls to the provided HubSpot library being "noisy" when my script was placed on a webserver and caused it to return information and freeze the rest of the script, I elected to abandon all usage of the HubSpot library and just use CURL for all my calls.
In the case of my above post about adding a note and the "hs_timestamp" validation issue, I thought I would post my basic code that I used to execute adding a note and associating a note successfully using CURL.
Be advised that while testing many "test notes" may get created and if you don't associate them they kind of sit on your app, you can use the API references "endpoint" sections to do "test posts" to list all notes, and then use all the ID's to delete the ones you don't want etc. Of course if you use a development account this isn't really an issue - I used an production account that isn't in use yet.
So on to the code...some of it is abbreviated, ommitted or changed, in favor of simplicity or privacy:
### Create The Note Code ###
//Get the current time in millliseconds for 'hs_timestamp'
Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success. Don't miss this opportunity to connect and grow—reserve your spot today!
Did you know that the Community is available in other languages? Join regional conversations by changing your language settings !