APIs & Integrations

vplatform
Participant

Get All Notes for a ticket

SOLVE

Hey all, 

 

I am currently trying to get a list of all the notes, along with their hs__note_body, or the body_preview (to pull the note message into our internal systems). I've been been looking over/sending requests to the Ticket/Notes/Engagements API's. So far I've only been able to do this by:

1) hitting https://api.hubapi.com/crm/v3/objects/tickets/{{ticketId}}?hapikey={{KEY_HERE}}&associations=engagments

to pull ticket Details and its associations to notes, example response below:

 

 

{
    "id": "...",
    "properties": {
....
    },
    "associations": {
        "engagements": {
            "results": [
                {
                    "id": "engagementId1",
                    "type": "ticket_to_engagement"
                },
                {
                    "id": "engagementId2",
                    "type": "ticket_to_engagement"
                },
                {
                    "id": "engagementId3",
                    "type": "ticket_to_engagement"
                },
                {
                    "id": "engagementId4",
                    "type": "ticket_to_engagement"
                }
            ]
        }
    }
}

 

 

then using the engagementIds from the above response to hit:

 

2)https://api.hubapi.com/engagements/v1/engagements/{{EngagmeentID}}?hapikey={{KEY_HERE}} to pull data for that 1 note (based on its engagementID) to get its bodyPreview. Example Below:

{
    "engagement": {
......
        "source": "CRM_UI",
        "allAccessibleTeamIds": [],
        "bodyPreview": "hi",
        "queueMembershipIds": [],
        "bodyPreviewIsTruncated": false,
        "bodyPreviewHtml": "<html>\n <head></head>\n <body>\n <p>hi</p>\n </body>\n</html>"
    },
    "associations": {
        "contactIds": [],
        "companyIds": [],
        "dealIds": [],
        "ownerIds": [],
        "workflowIds": [],
        "ticketIds": [
            1234
        ],
        "contentIds": [],
        "quoteIds": []
    },
    "attachments": [],
    "metadata": {
        "body": "<p>hi</p>"
    }
}

 

I would have to do this call several times, for every unique ticketId I wanted to gather Note body information from.

I haven't seen a batch "get all notes and their details, given a ticketId" endpoint - there's got to be a better way to do the above? this is the closest thing that I've seen in the forums, but it doesn't appear to be what we're looking for
https://community.hubspot.com/t5/APIs-Integrations/Getting-Latest-Notes-In-Tickets/m-p/571049#M50703

 

0 Upvotes
1 Accepted solution
aaylsworth
Solution
Participant

Get All Notes for a ticket

SOLVE

I recently used the /crm/v3/objects/notes/search endpoint to get a lost of notes associated with a certain custom objectId. Should be able to modify it for your use case.

// /crm/v3/objects/notes/search
{
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "hs_attachment_ids",
          "operator": "EQ",
          "value": "<<ticketId>>"
        }
      ]
    }
  ],
  "properties": [
    "hs_note_body"
  ]
}

 

View solution in original post

9 Replies 9
ChehakWadhdwa
Member | Diamond Partner
Member | Diamond Partner

Get All Notes for a ticket

SOLVE

hi vplatform 

You can directly get the notes using notes  engaments  API i.e. GET/crm/v3/objects/notes

refer to = https://developers.hubspot.com/docs/api/crm/notes, it already have the params hs__note_body which you want , you dont have  to calll a seperate API to achieve this 

 

Hope this helps! If we were able to answer your query, kindly help the community by marking it as a solution. Thanks and Regards.

0 Upvotes
vplatform
Participant

Get All Notes for a ticket

SOLVE

@ChehakWadhdwa 

I don't want to get a random list of all the notes possible (say we have 1,000 tickets created in our dashboard, then your above solution to just hit GET/crm/v3/objects/notes  would retrieve a paginated dump of all notes that exist, regardless of a specific ticketId). I want to specifiy a ticketId in the request above, and get a list of all notes for that ticketId

aaylsworth
Solution
Participant

Get All Notes for a ticket

SOLVE

I recently used the /crm/v3/objects/notes/search endpoint to get a lost of notes associated with a certain custom objectId. Should be able to modify it for your use case.

// /crm/v3/objects/notes/search
{
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "hs_attachment_ids",
          "operator": "EQ",
          "value": "<<ticketId>>"
        }
      ]
    }
  ],
  "properties": [
    "hs_note_body"
  ]
}

 

Mahfuz1
Participant

Get All Notes for a ticket

SOLVE

@aaylsworth what will be the propertyName?

 

returning 

{
    "total": 0,
    "results": []
}
even the data is there
0 Upvotes
psymon25
Member

Get All Notes for a ticket

SOLVE

Try this works my end

//https://api.hubapi.com/crm/v3/objects/notes/search

{
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "associations.ticket",
          "operator": "EQ",
          "value":"YOUR TICKET ID"
        }
      ]
    }
  ],
  "properties": ["hs_note_body"]
}

 

 

Mahfuz1
Participant

Get All Notes for a ticket

SOLVE

Thanks @psymon25 . It worked 

jaysonb
Participant

Get All Notes for a ticket

SOLVE

No response either? Everyone just points to the API docs. Trying to do this with contacts/deals. I want to get all notes associated with a contact_id.

0 Upvotes
laurabren
Contributor

Get All Notes for a ticket

SOLVE

@jaysonb just curious, did the solution @aaylsworth outlined work for your use case?

0 Upvotes
Mahfuz1
Participant

Get All Notes for a ticket

SOLVE

@laurabren no.

0 Upvotes