We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
May 19, 2021 4:46 AM
Hey guys,
I have a little problem: For some reason the following request returns a string as a response and not an object. All other requests in advance (which fill regEntry) work perfectly. The association is generated correctly. However, the answer is of the wrong data type.
I know I could work with JSON.parse (), but the API documentation clearly says that an object will be returned and that I should be able to rely on.
Any ideas?
I tried the following header
headers: { accept: 'application/json', 'content-type': 'application/json' }
headers: { accept: 'application/json' }
var requestAssocDealToContact = {
method: 'PUT',
url: 'https://api.hubapi.com/crm/v3/objects/deals/' + regEntry.deal.id + '/associations/contact/' + regEntry.contact.id + '/deal_to_contact',
qs: { hapikey: apiKey },
headers: { accept: 'application/json', 'content-type': 'application/json' }
};
request(requestAssocDealToContact, function (errorAssocDealToContact, responseAssocDealToContact, dataAssocDealToContact) {
if (errorAssocDealToContact)
throw new Error(errorAssocDealToContact);
regEntry.assocs.contactToDeal = dataAssocDealToContact.id;
responseJson.botMessage = typeof dataAssocDealToContact;
responseJson.customState = regEntry;
callback(responseJson);
});
Solved! Go to Solution.
May 19, 2021 5:13 AM
Nevermind 🙂
Accidentally deleted
json: true
inside the request object.
Thank y'all!
May 19, 2021 5:13 AM
Nevermind 🙂
Accidentally deleted
json: true
inside the request object.
Thank y'all!