APIs & Integrations

CBryant4
Participant

ParentID/ContactID for Notes?

When retrieving Contact Notes via your API, I currently receive a response containing something like this (for each note):

{
    "id": "123",
    "properties": {
        "hs_attachment_ids": null,
        "hs_createdate": "2022-07-27T00:20:07.839Z",
        "hs_lastmodifieddate": "2022-07-27T00:20:07.839Z",
        "hs_note_body": "This is the note text",
        "hs_object_id": "456",
        "hs_timestamp": "2022-03-28T04:00:00Z",
        "hubspot_owner_id": null
    },
    "createdAt": "2022-07-27T00:20:07.839Z",
    "updatedAt": "2022-07-27T00:20:07.839Z",
    "archived": false
}

 

My question is: from this data,  which field is the identifier for the Contact to which the Note is attached?  Is it the `hs_object_id`?

 

What I'm trying to do is look up the Contact information for each Note. 

0 Upvotes
2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

ParentID/ContactID for Notes?

Hey, @CBryant4 👋 Thanks for the great question! Can you share an example request? I noticed in the documentation that we need to include an additional param for associations to get back the associated Contact and its ID. Here's what I did:

  • Documentation – Retrieve Notes
  • Endpoint I used
    GET /crm/v3/objects/notes​
  • Request and added params
    https://api.hubapi.com/crm/v3/objects/notes?limit=10&properties=hs_note_body&associations=contact&archived=false​
  • Response body
    {
                "id": "24222024760",
                "properties": {
                    "hs_createdate": "2022-08-02T22:26:34.262Z",
                    "hs_lastmodifieddate": "2022-08-02T22:26:34.262Z",
                    "hs_note_body": "<div style=\"white-space: pre-wrap;\" dir=\"auto\" data-top-level=\"true\"><p style=\"margin-bottom:0;\">This is a second note. Cats are awesome</p></div>",
                    "hs_object_id": "24222024760"
                },
                "createdAt": "2022-08-02T22:26:34.262Z",
                "updatedAt": "2022-08-02T22:26:34.262Z",
                "archived": false,
                "associations": {
                    "contacts": {
                        "results": [
                            {
                                "id": "301",
                                "type": "note_to_contact"
                            }
                        ]
                    }
                }​
  • The value for “hs_object_id” is the engagement ID for the Note itself. We can verify this by navigating to a contact >Notes > Click the Actions dropdown > Copy link. If you paste the link into your browser, you'll see the “hs_object_id” matches the engagement ID at the end of the URL
    object-id-engagement-id.pngCleanShot 2022-08-02 at 16.39.52.png

Have fun coding! — Jaycee 

 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
CBryant4
Participant

ParentID/ContactID for Notes?

Hi @Jaycee_Lewis - thanks for your reply.  I tried a request similar to yours but still didn't get the associations returned.

 

Here is my (serialized) request, which I sent using the latest version of RestSharp:

 

 

{
    "AlwaysMultipartFormData": false,
    "MultipartFormQuoteParameters": false,
    "FormBoundary": null,
    "Parameters": [
        {
            "Name": "hapikey",
            "Value": "xxx",
            "Type": 4,
            "Encode": true,
            "ContentType": null
        },
        {
            "Name": "limit",
            "Value": "100",
            "Type": 4,
            "Encode": true,
            "ContentType": null
        },
        {
            "Name": "associations",
            "Value": "contact",
            "Type": 4,
            "Encode": true,
            "ContentType": null
        },
        {
            "Name": "archived",
            "Value": "false",
            "Type": 4,
            "Encode": true,
            "ContentType": null
        },
        {
            "Name": "properties",
            "Value": "hs_note_body,hs_timestamp",
            "Type": 4,
            "Encode": true,
            "ContentType": null
        }
    ],
    "Files": [],
    "Method": 0,
    "Timeout": 0,
    "Resource": "https://api.hubapi.com/crm/v3/objects/notes",
    "RequestFormat": 0,
    "RootElement": null,
    "OnBeforeDeserialization": null,
    "OnBeforeRequest": null,
    "OnAfterRequest": null,
    "Attempts": 0,
    "CompletionOption": 0,
    "ResponseWriter": null,
    "AdvancedResponseWriter": null
}

 

 

The URL (parameterized/encoded by RestSharp) looks like this:

 

 

https://api.hubapi.com/crm/v3/objects/notes?associations=contact&archived=false&limit=100&after=24016139891&properties=hs_note_body%2chs_timestamp

 

 

And here's a single record from the response content, which still doesn't contain the associations:

 

 

{
    "id": "24016139890",
    "properties": {
        "hs_createdate": "2022-07-27T22:01:53.380Z",
        "hs_lastmodifieddate": "2022-07-27T22:01:53.380Z",
        "hs_note_body": "CD 300005253 CLOSED 9/24/10 - MATURED AND LOOKING FOR HIGHER RATE",
        "hs_object_id": "24016139890",
        "hs_timestamp": "2010-09-24T04:00:00Z"
    },
    "createdAt": "2022-07-27T22:01:53.380Z",
    "updatedAt": "2022-07-27T22:01:53.380Z",
    "archived": false
}

 

 

 Any idea what I'm doing wrong?  I included `associations=contact` in the URL along with all the other querystring parameters.

 

[Edit: xxxed out the api key for security purposes]

0 Upvotes