APIs & Integrations

Stefan_PSV
Participante | Partner nivel Diamond
Participante | Partner nivel Diamond

API request returns string instead of object

resolver

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 Me gusta
1 Soluciones aceptada
Stefan_PSV
Solución
Participante | Partner nivel Diamond
Participante | Partner nivel Diamond

API request returns string instead of object

resolver

Nevermind 🙂
Accidentally deleted

json: true

inside the request object.

Thank y'all! 

Ver la solución en mensaje original publicado

0 Me gusta
1 Respuesta 1
Stefan_PSV
Solución
Participante | Partner nivel Diamond
Participante | Partner nivel Diamond

API request returns string instead of object

resolver

Nevermind 🙂
Accidentally deleted

json: true

inside the request object.

Thank y'all! 

0 Me gusta