APIs & Integrations

RKhan1
Membre

update an existing contact on hubspot through api

Résolue

I need to update a contact on hubspot from my webapp. In order to accomplish this I followed the official guide. Here what I did:

I have this kind of contact:

myContact = {
    firstname: 'Mick',
    lastname: 'Junior',
    email: 'mj@email.com',
}

From my webapp I make a ceate request with the object above. It successfully creates a contact on the hubspot platform.

At this point I have this contact on Hubspot. If i get it, the response will be the following:

  SimplePublicObject {
    id: '16401',
    properties: {
      createdate: '2021-04-19T09:33:24.808Z',
      email: 'mj@email.com',
      firstname: 'Mick',
      hs_object_id: '16401',
      lastmodifieddate: '2021-04-19T09:33:26.094Z',
      lastname: 'Junior',
    },
    createdAt: 2021-04-19T09:33:24.808Z,
    updatedAt: 2021-04-19T09:33:26.094Z,
    associations: undefined,
    archived: false,
    archivedAt: undefined
  },

Let's say that I made a mistake and I want to modify the lastname into Senior. So I do the following:

const hubspotClient = new hubspot.Client({
  apiKey: MY_KEY
});
const myNewContact = {
    id: '16401',
    properties:{
        firstname: 'Mick',
        lastname: 'Senior',
        email: 'mj@email.com',
    }
  }
await hubspotClient.crm.deals.batchApi.update({
  inputs:[myNewContact]
});

This doesn't throw any error, but on Hubspot platform, the contact is still the old one. All I did seems to have sense but it doesn't work..

Here is the response of the Hubspot update request

0 Votes
1 Solution acceptée
dennisedson
Solution
Équipe de développement de HubSpot
Équipe de développement de HubSpot

update an existing contact on hubspot through api

Résolue

@RKhan1 

Looks like you are calling deals when you want to be calling for contacts in your await

hubspotClient.crm.deals.batchApi.update

should be

hubspotClient.crm.contacts.batchApi.update(

Voir la solution dans l'envoi d'origine

1 Réponse
dennisedson
Solution
Équipe de développement de HubSpot
Équipe de développement de HubSpot

update an existing contact on hubspot through api

Résolue

@RKhan1 

Looks like you are calling deals when you want to be calling for contacts in your await

hubspotClient.crm.deals.batchApi.update

should be

hubspotClient.crm.contacts.batchApi.update(