APIs & Integrations

TYona
Membro

Associate Ticket to contact

resolver

Hi

I am trying to associate between a ticket to a contact using the hubspot api  - node.js but having trouble would apreciate for an example on how to do it.

Thanks!

1 Solução aceita
TYona
Solução
Membro

Associate Ticket to contact

resolver

Actually I managed! The problem was with js rather then the api itself.

Thanks Quentin!

Exibir solução no post original

0 Avaliação positiva
8 Respostas 8
quentin_lamamy
Conselheiro(a) de destaque | Parceiro Diamante
Conselheiro(a) de destaque | Parceiro Diamante

Associate Ticket to contact

resolver

If your issue is solved don't forget to flag your post as solved.


0 Avaliação positiva
quentin_lamamy
Conselheiro(a) de destaque | Parceiro Diamante
Conselheiro(a) de destaque | Parceiro Diamante

Associate Ticket to contact

resolver

Hi,

 

Can you give me the link of the documentation you are following and post the dump of createTicketResponse


0 Avaliação positiva
TYona
Solução
Membro

Associate Ticket to contact

resolver

Actually I managed! The problem was with js rather then the api itself.

Thanks Quentin!

0 Avaliação positiva
quentin_lamamy
Conselheiro(a) de destaque | Parceiro Diamante
Conselheiro(a) de destaque | Parceiro Diamante

Associate Ticket to contact

resolver

Hi, I don't have the documentation of the node sdk , you should check first the parameter of the method. If the expected first parameter of the method is the ticket id you should check if createTicketResponse.body contain the id, please check doc, dump the value and post here the value of this variable


TYona
Membro

Associate Ticket to contact

resolver

Hi,

Thanks again!

After checking it seems that the id is undefined.

I used this documentation, still no luck with assocation of a contact to a ticket. 

I'd appreciate an example of it using the sdk from someone in the community 🙂

Thanks!

0 Avaliação positiva
quentin_lamamy
Conselheiro(a) de destaque | Parceiro Diamante
Conselheiro(a) de destaque | Parceiro Diamante

Associate Ticket to contact

resolver

Hi @TYona 

 

- Can you post your code (inside a code bloc, the </> icon in the formatting toolbar) so that i can help you.
- What's is your issue ? An error messsage as api response ? If yes which one


TYona
Membro

Associate Ticket to contact

resolver

Thanks @quentin_lamamy !

Below you may find the code and the error

the error is: UnhandledPromiseRejectionWarning: Error: Required parameter ticketId was null or undefined when calling create.
at AssociationsApi.

const hubspot = require('@hubspot/api-client')
const hubspotClient = new hubspot.Client({apiKey: 'MYAPIKEY'})

const contactObj = {
    properties: {
        firstname: 'T',
        lastname: 'Test',
        email: 'ty@example.com',
        company: 'Texample'
    },
}
const ticketObj = {
    properties: {
        "hs_pipeline": "0",
        "hs_pipeline_stage": "1",
        "hs_ticket_priority": "HIGH",
        "hubspot_owner_id": "5555555",
        "subject": "test association"
    }
};
// create ticket
const createTicketResponse = hubspotClient.crm.tickets.basicApi.create(ticketObj)
// create contact
const createContactResponse = hubspotClient.crm.contacts.basicApi.create(contactObj)
function addTicket(){
    return hubspotClient.crm.tickets.associationsApi.create(createTicketResponse.body, "tickets", createContactResponse.body, "", undefined, undefined)

}

addTicket()
    .then(console.log('done'))
    .catch(console.log('error'))

 

TShma
Colaborador(a)

Associate Ticket to contact

resolver

This is an old thread and I'm sure it was solved, yet if someone arrives here with the same issue, you should have supplied the ticketId and the contactId, respectively, wherever you've send the body of the response.