APIs & Integrations

TYona
Membre

Associate Ticket to contact

Résolue

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 Solution acceptée
TYona
Solution
Membre

Associate Ticket to contact

Résolue

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

Thanks Quentin!

Voir la solution dans l'envoi d'origine

0 Votes
8 Réponses
quentin_lamamy
Conseiller clé | Partenaire solutions Diamond
Conseiller clé | Partenaire solutions Diamond

Associate Ticket to contact

Résolue

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


0 Votes
quentin_lamamy
Conseiller clé | Partenaire solutions Diamond
Conseiller clé | Partenaire solutions Diamond

Associate Ticket to contact

Résolue

Hi,

 

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


0 Votes
TYona
Solution
Membre

Associate Ticket to contact

Résolue

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

Thanks Quentin!

0 Votes
quentin_lamamy
Conseiller clé | Partenaire solutions Diamond
Conseiller clé | Partenaire solutions Diamond

Associate Ticket to contact

Résolue

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
Membre

Associate Ticket to contact

Résolue

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 Votes
quentin_lamamy
Conseiller clé | Partenaire solutions Diamond
Conseiller clé | Partenaire solutions Diamond

Associate Ticket to contact

Résolue

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
Membre

Associate Ticket to contact

Résolue

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
Contributeur

Associate Ticket to contact

Résolue

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.