APIs & Integrations

RKhan1
メンバー

update an existing contact on hubspot through api

解決

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 いいね!
1件の承認済みベストアンサー
dennisedson
解決策
HubSpot製品開発チーム
HubSpot製品開発チーム

update an existing contact on hubspot through api

解決

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

元の投稿で解決策を見る

1件の返信
dennisedson
解決策
HubSpot製品開発チーム
HubSpot製品開発チーム

update an existing contact on hubspot through api

解決

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