# Hubspot Client Libraries ERROR: Cannot parse content. No Content-Type defined

**URL:** <https://community.hubspot.com/t/hubspot-client-libraries-error-cannot-parse-content-no-content-type-defined/123436>\
**Category:** APIs & Integrations\
**Tags:** workflows\
**Created:** [January 7, 2025, 5:47pm UTC](https://community.hubspot.com/t/hubspot-client-libraries-error-cannot-parse-content-no-content-type-defined/123436 "2025-01-07T17:47:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rocketman22](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rocketman22](https://community.hubspot.com/u/rocketman22)\
**Post date:** [January 7, 2025, 5:47pm UTC](https://community.hubspot.com/t/hubspot-client-libraries-error-cannot-parse-content-no-content-type-defined/123436/1 "2025-01-07T17:47:25Z")

</div>

Hello,  
I have developed a custom code snippet for a contact-based workflow that updates a record of a custom object associated with the contact. In this code I am using the Hubspot library, more specifically the update method, as shown in the following code:

```lia-code-sample
const hubspot = require('@hubspot/api-client');

exports.main = async (event) => {
 const hubspotClient = new hubspot.Client({ accessToken: process.env.TOKEN_CUSTOM_OBJECTS });
 const current_object_id = event.inputFields['current_object_id']; 

 const new_properties = {
 properties: {
 hs_pipeline: 123456789,
 hs_pipeline_stage: 987654321,
 property_1: event.inputFields['property_1'],
 property_2: event.inputFields['property_2'],
 property_3: event.inputFields['property_3'],
 }
 }; 

 await hubspotClient.crm.objects.basicApi.update("2-########", current_object_id, new_properties, undefined);
}

```

Randomly, I receive an error notification in this custom code, containing the following response:

`ERROR	Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: Cannot parse content. No Content-Type defined.","reason":{"errorType":"Error","errorMessage":"Cannot parse content. No Content-Type defined.","stack":["Error: Cannot parse content. No Content-Type defined."," at ObjectSerializer.parse (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/objects/models/ObjectSerializer.js:311:19)"," at BasicApiResponseProcessor.<anonymous> (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/objects/apis/BasicApi.js:282:114)"," at Generator.next (<anonymous>)"," at fulfilled (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/objects/apis/BasicApi.js:5:58)"," at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: Cannot parse content. No Content-Type defined."," at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)"," at process.emit (node:events:519:28)"," at emitUnhandledRejection (node:internal/process/promises:250:13)"," at throwUnhandledRejectionsMode (node:internal/process/promises:385:19)"," at processPromiseRejections (node:internal/process/promises:470:17)"," at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}`

These errors do not happen very often, but for some time now 2 to 3 cases have been appearing per day.

Could someone help me understand what might be happening?

Thanks,

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 8, 2025, 5:26pm UTC](https://community.hubspot.com/t/hubspot-client-libraries-error-cannot-parse-content-no-content-type-defined/123436/2 "2025-01-08T17:26:23Z")

</div>

Hey, @rocketman22 👋 Thanks for your question. I don’t have an answer to your issue, but I have a few suggestions. Have you tried:

- Adding error handing with a try-catch block?
- Explicitly setting your Content-Type header?
- Adding retry logic

Something like:

```lia-code-sample
const hubspot = require('@hubspot/api-client');

exports.main = async (event) => {
 const hubspotClient = new hubspot.Client({ accessToken: process.env.TOKEN_CUSTOM_OBJECTS });
 const current_object_id = event.inputFields['current_object_id']; 

 const new_properties = {
 properties: {
 hs_pipeline: 123456789,
 hs_pipeline_stage: 987654321,
 property_1: event.inputFields['property_1'],
 property_2: event.inputFields['property_2'],
 property_3: event.inputFields['property_3'],
 }
 }; 

 try {
 // Let's add retry logic
 let retries = 3;
 let success = false;
 let lastError;

 while (retries > 0 && !success) {
 try {
 await hubspotClient.crm.objects.basicApi.update(
 "2-########", 
 current_object_id, 
 new_properties,
 {
 headers: {
 'Content-Type': 'application/json'
 }
 }
 );
 success = true;
 } catch (error) {
 lastError = error;
 retries--;
 if (retries > 0) {
 // Pause for the cause. Wait for 1 second before retrying
 await new Promise(resolve => setTimeout(resolve, 1000));
 }
 }
 }

 if (!success) {
 throw lastError;
 }
 } catch (error) {
 // Log the error 
 console.error('Error updating HubSpot object:', {
 objectId: current_object_id,
 error: error.message,
 stack: error.stack
 });
 throw error; // Re-throw if you want the workflow to fail
 }
}

```

I hope this helps. Have fun testing! — Jaycee

---

<div class="post-metadata">

**Author:** ![rocketman22](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rocketman22](https://community.hubspot.com/u/rocketman22)\
**Post date:** [January 9, 2025, 3:44pm UTC](https://community.hubspot.com/t/hubspot-client-libraries-error-cannot-parse-content-no-content-type-defined/123436/3 "2025-01-09T15:44:55Z")

</div>

Hi [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074),

Thank you very much for your reply!

I really liked your suggestions, they seem like good practices that I hadn’t considered.

I’m going to analyze and apply them to my code and see if the errors stop.

Cheers,
