Skip to content

Creating association as indicated by documentation does not work #271

@cacique-coder

Description

@cacique-coder

I was reading the documentation and it does not work as the code indicate.

it raise and error not finding a file "models/object_type"

However running the CURL command it works perfectly.

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

I've tested with versions 17.1 and 17.2

# this code fails
require 'hubspot-api-client'

api_client = Hubspot::Client.new(access_token: 'YOUR_ACCESS_TOKEN')

api_response = api_client.crm.objects.basic_api.create(object_type: "deals", object_id: "DEAL_ID", to_object_type: "contacts", to_object_id: "CONTACT_ID", association_spec: [{"associationCategory":"USER_DEFINED","associationTypeId":ASSOCIATION_ID}])
# This command works
curl --request PUT \
  --url https://api.hubapi.com/crm/v4/objects/deals/DEAL_ID/associations/contacts/CONTACT_ID \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '[
  {
    "associationCategory": "USER_DEFINED",
    "associationTypeId": ASSOCIATION_ID
  }
]'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions