Oct 12, 2022 11:49 AM - edited Oct 14, 2022 6:52 AM
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 😁.
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 - 😉 but after one hour and half, it's not working.
😮
While typing the message I've just understood I was dumping the $noteInput instead of the $note ! Damned 😂
Thank you for your support everyone, hope the snippet will help someone in the future ! 🤠
Solved! Go to Solution.
Oct 12, 2022 4:51 PM
Hey, @ph_alti_trading 👋 To confirm, you found your mistake and added the solution? If so, please add a comment and I can mark it as solved ✅
Thank you! — Jaycee
Oct 13, 2022 4:17 AM
Yes @Jaycee_Lewis I found my mistake while I was writing my message so I posted the solution anyway 😃 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 😅...
I guess next time I call it a day before pushing into the debug 😎
Oct 12, 2022 4:51 PM
Hey, @ph_alti_trading 👋 To confirm, you found your mistake and added the solution? If so, please add a comment and I can mark it as solved ✅
Thank you! — Jaycee
Oct 13, 2022 4:17 AM
Yes @Jaycee_Lewis I found my mistake while I was writing my message so I posted the solution anyway 😃 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 😅...
I guess next time I call it a day before pushing into the debug 😎