APIs & Integrations

AArtiles
Member

INVALID_ASSOCIATION_TYPE error when associating a contact to a ticket

Hello,

I'm using the official node.js SDK to create a ticket and associate it to a contact.

 

 

  async function createFullTicket(options) {
    const ticket = await hubspotClient.crm.tickets.basicApi.create(options.ticket);

    const contact = await hubspotClient.crm.contacts.basicApi.create(options.contact);


    return await hubspotClient.crm.tickets.associationsApi.create(ticket.body.id, 'contacts', contact.body.id, 'contact_to_ticket');
  }

 

 

Both the ticket and the contact are successfully created but the association fails with the following error body:

 

{
      status: 'error',
      message: 'contact_to_ticket is not a valid association type between tickets and contacts',
      correlationId: 'dceb010e-14b9-4a7c-8d9c-5887498d4ba6',
      context: Object {
        type: Array [ 'contact_to_ticket' ],
        fromObjectType: Array [ 'tickets' ],
        toObjectType: Array [ 'contacts' ]
      },
      category: 'VALIDATION_ERROR',
      subCategory: 'crm.associations.INVALID_ASSOCIATION_TYPE'
    }
  }

 

I haven't been able to find documentation for the parameters. 

Thanks 

 

 

 

 

 

2 Replies 2
AArtiles
Member

INVALID_ASSOCIATION_TYPE error when associating a contact to a ticket

I managed to create the association by changing the type to `ticket_to_contact`. Now I have another problem if I try to create a ticket for an existing contact because the create contact endpoint returns  

{
      status: 'error',
      message: 'Contact already exists. Existing ID: 187428246',
      correlationId: 'e45b8745-c178-4b67-9f39-58a8f2753bc5',
      category: 'CONFLICT'
    }
  }

Probably I don't understand well how the Tickets feature works. What I am trying to achieve is quite simple: I'm migrating our tickets systems from Zendesk to Hubspot, so I want to create a ticket given an email address, a subject, and the ticket's content. I expect it to be as simple as calling an endpoint with those 3 parameters but it seems that I need to know well how HubSpot objects interconnect. 

webdew
Guide | Diamond Partner
Guide | Diamond Partner

INVALID_ASSOCIATION_TYPE error when associating a contact to a ticket

Hi @AArtiles ,

Hope this will work for you.

If you want to associate contact object type with ticket. which is already associated but if want to associated then use this documentation. https://developers.hubspot.com/blog/introducing-custom-objects-for-hubspot


AND


If you want to associate each contacts with each tickets then use below instructions
Please use this code for associated with contact id to tickets id

https://api.hubapi.com/crm-associations/v1/associations?hapikey=demo

Example PUT JSON:
{
"fromObjectId": <contactId>,
"toObjectId": <ticketId>,
"category": "HUBSPOT_DEFINED",
"definitionId": 15
}

Definations ID :
https://prnt.sc/1bppu9g

Link : https://legacydocs.hubspot.com/docs/methods/crm-associations/associate-objects


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

0 Upvotes