Retrieve Association with Tasks

I have following endpoint with contactId which associated with task, and I want to fetch task details with association of contact. Check below screenshot where I’m hitting the endpoint but I gets an error of infer object.

Anybody there who can suggest on this and guide me to fetch associated object with Task.

Regards,

@teja21

Hi @teja21,

The reason you are encountering this issue is due to an invalid value being supplied in the “associations” query parameter. In your case it seems as though you’d like to get the associated contacts linked to the task. If that is the case you can use the CRM APIs, specifically GET /crm/v3/objects/tasks as follows:

GET https://api.hubapi.com/crm/v3/objects/tasks?associations=contacts
RESPONSE
{
 "results": [
 {
 "id": "31319162089",
 "properties": {
 "hs_createdate": "2024-08-08T14:26:07.802Z",
 "hs_lastmodifieddate": "2024-08-13T07:01:33.124Z",
 "hs_object_id": "31319162089"
 },
 "createdAt": "2024-08-08T14:26:07.802Z",
 "updatedAt": "2024-08-13T07:01:33.124Z",
 "archived": false,
 "associations": {
 "contacts": {
 "results": [
 {
 "id": "28333023942",
 "type": "task_to_contact"
 }
 ]
 }
 }
 }
 ]
}

Notice in the above example I specifcy “associations=contacts”. The response contains the IDs of any associated contacts in the “associations” object. I can then pull information on the contact using GET /crm/v3/objects/contacts/{contactId}.

I hope this helps!

Jack