APIs & Integrations

ph_alti_trading
Contributor

Create a Note with the V3

SOLVE

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 ! 🤠

2 Accepted solutions
Jaycee_Lewis
Solution
Community Manager
Community Manager

Create a Note with the V3

SOLVE

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

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

ph_alti_trading
Solution
Contributor

Create a Note with the V3

SOLVE

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 😎

View solution in original post

0 Upvotes
2 Replies 2
Jaycee_Lewis
Solution
Community Manager
Community Manager

Create a Note with the V3

SOLVE

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

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

ph_alti_trading
Solution
Contributor

Create a Note with the V3

SOLVE

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 😎

0 Upvotes