APIs & Integrations

jfrubiod
Member

Private app - Cant create asociations in task

Hi. 

Im creating one task in PHP and I need to setup an associtaion with a company using V3 CRM connection.

 

There is no problem with the task but the association was not stablished. I use this data for create.

 

Where I could find a definition to know wich is de code that I need for "copany" in "associationTypeId" field.

 

Thanks

 

 

 

 

	$simplePublicObjectInputForCreate = [
		'properties' => [
				  "hs_timestamp" => $date,
				  "hs_task_body" => $cuerpo,
				  "hubspot_owner_id" => $owner,
				  "hs_task_subject" => $titulo,
				  "hs_task_status" => "WAITING",
				  "hs_task_priority" => "HIGH"
			],
		'asociations' => [
				"to" => [
					"id" => $company,
					"types" => [
						"associationCategory" => "HUBSPOT_DEFINED",
						"associationTypeId" => 2
					]
				]
			]
	];

 

 

 

 

0 Upvotes
1 Reply 1
Jaycee_Lewis
Community Manager
Community Manager

Private app - Cant create asociations in task

Hi, @jfrubiod 👋 Thanks for the question. This one always feels a bit mysterious until you know where to look 😊 

You can find this information between two objects by using this endpoint — Retrieve association types

  • GET /crm/v4/associations/{fromObjectType}/{toObjectType}/labels

Here's an example:

  • my request
    GET https://api.hubapi.com/crm/v4/associations/task/company/labels​
  • the response
    {
        "results": [
            {
                "category": "HUBSPOT_DEFINED",
                "typeId": 192,
                "label": null
            }
        ]
    }​

You could do the same Task > Contact, for example, to get the typeId. Each ID is one-way, please verify you specify the correct objects and association direction.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes