# API request returns string instead of object

**URL:** <https://community.hubspot.com/t/api-request-returns-string-instead-of-object/37569>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, professional, object, contacts\
**Created:** [May 19, 2021, 8:46am UTC](https://community.hubspot.com/t/api-request-returns-string-instead-of-object/37569 "2021-05-19T08:46:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_PSV](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stefan_psv/32/73373_2.png) [@Stefan\_PSV](https://community.hubspot.com/u/Stefan_PSV)\
**Post date:** [May 19, 2021, 8:46am UTC](https://community.hubspot.com/t/api-request-returns-string-instead-of-object/37569/1 "2021-05-19T08:46:17Z")

</div>

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

```lia-code-sample
headers: { accept: 'application/json', 'content-type': 'application/json' }

headers: { accept: 'application/json' }

```

```lia-code-sample
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);
 });

```

---

<div class="post-metadata">

**Author:** ![Stefan\_PSV](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stefan_psv/32/73373_2.png) [@Stefan\_PSV](https://community.hubspot.com/u/Stefan_PSV)\
**Post date:** [May 19, 2021, 9:13am UTC](https://community.hubspot.com/t/api-request-returns-string-instead-of-object/37569/2 "2021-05-19T09:13:35Z")

</div>

Nevermind 🙂  
Accidentally deleted

`json: true`

inside the request object.  
Thank y’all!
