Create a Note with the V3

Hello Ladies & Gentleman.
I’m stuck in creating a note via the API :

<?php

define( 'HUBSPOT_BASE_URL', 'https://api.hubapi.com' );
define( 'HUSPOT_ACCESS_TOKEN', '****-*****-********' );

require_once "./vendor/autoload.php";

$client = \HubSpot\Factory::createWithAccessToken(HUSPOT_ACCESS_TOKEN);

$noteProperties = [
 "properties" => [
 "hs_timestamp" => "2022-09-19T03:30:17.883Z",
 "hs_note_body" => "Spoke with decision maker john",
 "hubspot_owner_id" => "1234567"
 ] 
];

$noteInput = new \HubSpot\Client\Crm\Objects\Notes\Model\SimplePublicObjectInput($noteProperties);

$note = $hubspot->crm()->objects()->notes()->basicApi()->create($noteInput);

var_dump( $note );

?>

I guess it’s working (result 201 or 200 in the log) but the returned result looks like this :

object(HubSpot\Client\Crm\Objects\Notes\Model\SimplePublicObjectInput)#17 (1) {
 ["container":protected]=>
 array(1) {
 ["properties"]=>
 array(3) {
 ["hs_timestamp"]=>
 string(24) "2022-09-19T03:30:17.883Z"
 ["hs_note_body"]=>
 string(30) "Spoke with decision maker john"
 ["hubspot_owner_id"]=>
 string(8) "1234567"
 }
 }
}

The ID is missing :grin:.

I need this ID in order to associate the note to a deal. I checked with different timestamp and different owner ids - yeah not owners ids not contact ids - :wink: but after one hour and half, it’s not working.

:open_mouth:

While typing the message I’ve just understood I was dumping the $noteInput instead of the $note ! Damned :joy:

Thank you for your support everyone, hope the snippet will help someone in the future ! :cowboy_hat_face:

Hey, @ph_alti_trading :waving_hand: To confirm, you found your mistake and added the solution? If so, please add a comment and I can mark it as solved :white_check_mark:

Thank you! — Jaycee

Yes @Jaycee_Lewis I found my mistake while I was writing my message so I posted the solution anyway :smiley: I tested it and the call to the API V3 is working !
The variable set in the var_dump to debug was not the right one :sweat_smile:…
I guess next time I call it a day before pushing into the debug :smiling_face_with_sunglasses: