update an existing contact on hubspot through api

SOLVE
RKhan1
Member

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 Upvotes
1 Accepted solution

Accepted Solutions
dennisedson
Solution
Community Manager

@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(
Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content

View solution in original post

0 Upvotes
1 Reply 1
dennisedson
Solution
Community Manager

@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(
Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content

View solution in original post

0 Upvotes