APIs & Integrations

EIbbetson
Participant

Batch Create associations

SOLVE

Using this documentation:

https://developers.hubspot.com/docs/api/crm/contacts

 

Using this link under /crm/v3/objects/contacts/batch/create

Says I can add Associations to it:

 

const BatchInputSimplePublicObjectInputForCreate = { inputs: [{"properties":{"company":"Biglytics","email":"bcooper@biglytics.net","firstname":"Bryan","lastname":"Cooper","phone":"(877) 929-0687","website":"biglytics.net"},"associations":[{"to":{"id":"6405179454"},"types":[{"associationCategory":"USER_DEFINED","associationTypeId":1}]}]}] };

 

When I do this, I get an error:

Contact creates with Associations not supported

 

I knew originally you had to do the Association separately but this is a direct copy/paste from the Documentation guide.

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Batch Create associations

SOLVE

Hey, @EIbbetson 👋 Thanks for taking the time to flag this. I ran a quick test and got the same result. 

 

Example:

Request

curl --request POST \
  --url https://api.hubapi.com/crm/v3/objects/contacts/batch/create \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "inputs": [
    {
      "properties": {
        "company": "Jimmy Pesto'\''s Pizzeria",
        "email": "jimmyjr@jimmypestopizzeria.com",
        "firstname": "Jimmy Jr",
        "lastname": "Pesto",
        "phone": "(877) 929-0687",
        "website": "http://jimmypestopizzeria.com"
      },
      "associations": [
        {
          "to": {
            "id": "10202231595"
          },
          "types": [
            {
              "associationCategory": "HUBSPOT_DEFINED",
              "associationTypeId": 1
            }
          ]
        }
      ]
    }
  ]
}'

Response

HTTP 400

{
  "status": "error",
  "message": "Contact creates with Associations not supported.",
  "errorTokens": {
    "failedRequests": [
      "This failed createObjectRequest is of type contact and contains the following associations: [AssociationSpecAndObjectIds{associationSpec=AssociationSpec{associationCategory=HUBSPOT_DEFINED, associationTypeId=1}, objectIds=[10202231595]}]"
    ]
  },
  "correlationId": "3ec31fe7-17cd-4e49-ad93-6e150f2f8202"
}

 

I'll take your example and mine, and get this to the team that owns the dev docs. I agree, this is confusing to offer an option that is explicitly called out as not possible in the accompanying documentation:

Please note: you cannot create a contact and associate it with a record or activity in the same request. To associate your contact with other records or activities, create the contact, then update the contact or create an association via the associations API.

 

Thanks again! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

0 Upvotes
2 Replies 2
Jaycee_Lewis
Solution
Community Manager
Community Manager

Batch Create associations

SOLVE

Hey, @EIbbetson 👋 Thanks for taking the time to flag this. I ran a quick test and got the same result. 

 

Example:

Request

curl --request POST \
  --url https://api.hubapi.com/crm/v3/objects/contacts/batch/create \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "inputs": [
    {
      "properties": {
        "company": "Jimmy Pesto'\''s Pizzeria",
        "email": "jimmyjr@jimmypestopizzeria.com",
        "firstname": "Jimmy Jr",
        "lastname": "Pesto",
        "phone": "(877) 929-0687",
        "website": "http://jimmypestopizzeria.com"
      },
      "associations": [
        {
          "to": {
            "id": "10202231595"
          },
          "types": [
            {
              "associationCategory": "HUBSPOT_DEFINED",
              "associationTypeId": 1
            }
          ]
        }
      ]
    }
  ]
}'

Response

HTTP 400

{
  "status": "error",
  "message": "Contact creates with Associations not supported.",
  "errorTokens": {
    "failedRequests": [
      "This failed createObjectRequest is of type contact and contains the following associations: [AssociationSpecAndObjectIds{associationSpec=AssociationSpec{associationCategory=HUBSPOT_DEFINED, associationTypeId=1}, objectIds=[10202231595]}]"
    ]
  },
  "correlationId": "3ec31fe7-17cd-4e49-ad93-6e150f2f8202"
}

 

I'll take your example and mine, and get this to the team that owns the dev docs. I agree, this is confusing to offer an option that is explicitly called out as not possible in the accompanying documentation:

Please note: you cannot create a contact and associate it with a record or activity in the same request. To associate your contact with other records or activities, create the contact, then update the contact or create an association via the associations API.

 

Thanks again! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
PRao5
Participant

Batch Create associations

SOLVE

Hello, I am also facing same issue. So, Is the end point defination is wrong? I still confused, do we create association to the new user creation. If not please remove it from the documentation

/crm/v3/objects/contacts/batch/create