Contacts.createOrUpdate data object issue
See original GitHub issueThis may be a typscript specific issue. When i try to use the contacts.createOrUpdate method i get an error. It requires two inputs into it. a string which would be the email and a data object. All the other methods like create require a JSON object but when i try to use it like this:
const contact_data = { 'properties': [ { "property": "email", "value": postData.email }, { "property": "firstname", "value": postData.f_name }, { "property": "lastname", "value": postData.l_name }, { "property": "company", "value": postData.company }, { "property": "phone", "value": postData.phone }, { "property": "state", "value": postData.state } ] };
it gives me this error:
[ts] Argument of type '{ 'properties': { "property": string; "value": any; }[]; }' is not assignable to parameter of type '{}[]'. Property 'length' is missing in type '{ 'properties': { "property": string; "value": any; }[]; }'.
i make the call like this:
return hubspot.contacts.createOrUpdate(postData.email, contact_data)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:17 (6 by maintainers)
I have the same issue, according to the doc (https://developers.hubspot.com/docs/methods/contacts/create_or_update) data should
createOrUpdate(email: string, data: {}): RequestPromise
like:create(data: {}): RequestPromise
instead ofcreateOrUpdate(email: string, data: any[]): RequestPromise
. Maybe it’s also impact others API routes that you modify in #112@Elyx0 which version are you using?
2.2 incorporates the fix described above: https://github.com/MadKudu/node-hubspot/blob/master/lib/typescript/contact.ts#L29