APIs & Integrations

Stefan_PSV
Participant | Diamond Partner
Participant | Diamond Partner

API request returns string instead of object

SOLVE

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);
      });

 

0 Upvotes
1 Accepted solution
Stefan_PSV
Solution
Participant | Diamond Partner
Participant | Diamond Partner

API request returns string instead of object

SOLVE

Nevermind 🙂
Accidentally deleted

json: true

inside the request object.

Thank y'all! 

View solution in original post

0 Upvotes
1 Reply 1
Stefan_PSV
Solution
Participant | Diamond Partner
Participant | Diamond Partner

API request returns string instead of object

SOLVE

Nevermind 🙂
Accidentally deleted

json: true

inside the request object.

Thank y'all! 

0 Upvotes