Tickets associations

I’ve been trying to pull emails, tasks, and notes for each of my tickets through the HubSpot API. Basically, I wanted to obtain the association IDs and then call the Engagements API to retrieve that data. I was following this process: https://community.hubspot.com/t5/APIs-Integrations/Get-all-emails-for-a-ticket/m-p/829716

However, I’m encountering a problem: for all my tickets, the associations section shows a ‘None’ value. What could be the problem? Could it be a very specific issue with my account?

I am using Python, and this is the offical code provided by HubSpot:

import hubspotfrom pprint import pprintfrom hubspot.crm.objects import ApiExceptionclient = hubspot.Client.create(access_token="----API----")try:api_response = client.crm.objects.basic_api.get_by_id(object_type="tickets", object_id="2545436276", archived=False)pprint(api_response)except ApiException as e:print("Exception when calling basic_api->get_by_id: %s\n" % e)

You probably need to add the associations param in your call.

api_response = client.crm.objects.basic_api.get_by_id(object_type="tickets", object_id="2545436276", associations=["emails", "notes", ....], archived=False)

@RRompich - honestly, I don’t think you are making the API call you think you are here. Its a bit obscured by the hubspot client code library conventions.

Although the original thread suggested a v3 objects API, I would be very tempted to directly use the most current v4 API code for this:

GET/crm/v4/objects/{objectType}/{objectId}/associations/{toObjectType}

Which will list all types of associations - HubSpot and user defined - although that may not be as useful here as it is in other places.

I tested this out and it seems to provide full information required.

Hope this works for you!

Steve

``