# Import API 400 Bad Request no meaningful error message

**URL:** <https://community.hubspot.com/t/import-api-400-bad-request-no-meaningful-error-message/131080>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [May 5, 2025, 6:24pm UTC](https://community.hubspot.com/t/import-api-400-bad-request-no-meaningful-error-message/131080 "2025-05-05T18:24:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSun7](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@SSun7](https://community.hubspot.com/u/SSun7)\
**Post date:** [May 5, 2025, 6:24pm UTC](https://community.hubspot.com/t/import-api-400-bad-request-no-meaningful-error-message/131080/1 "2025-05-05T18:24:17Z")

</div>

I’m working on an integration that requires using Import API. I’m testing it with a small csv file (only contains two lines and around 10 columns) locally. I’ve tested with Postman with the csv file and request body, and the data was imported successfully.

Then I tried to do the same API call in the server, with the following lines:

const csvPath = path.join(\_\_dirname, ‘myfile.csv’);

const fileContent = fs.createReadStream(csvPath);

const formData = new FormData();

formData.append(‘importRequest’, requestStr); formData.append(‘files’, fileContent);

const response = await axios.post(`[https://api.hubapi.com/crm/v3/imports/\`](https://api.hubapi.com/crm/v3/imports/%5C%60), formData, {headers: { Authorization: 'Bearer ’ + oauthToken.accessToken, ‘Content-Type’: ‘multipart/form-data’ }});

I’ve confirmed the requestStr is the same as in Postman (in fact, I got the requestStr here first then pasted it in Postman), and the csv file is also the same. However, the request keeps returning a 400 bad request error. Could anyone provide insights here on any potential causes?

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [May 6, 2025, 10:51am UTC](https://community.hubspot.com/t/import-api-400-bad-request-no-meaningful-error-message/131080/2 "2025-05-06T10:51:16Z")

</div>

Hi @SSun7, I hope that you are well!

Thanks for reaching out to the HubSpot Community!  
While looking around the Community, I did find several threads that you might want to check out:  
- The solution from @YGhimire on this post “[Getting 400 Bad Request](https://community.hubspot.com/t5/APIs-Integrations/Getting-400-Bad-Request/m-p/467749)”  
- The solution from @jjovick on this post “[(400) Bad Request](https://community.hubspot.com/t5/APIs-Integrations/400-Bad-Request/m-p/236059)”  
- The solution from my colleague Jaycee on this post “[400 Error on POST to Contacts API](https://community.hubspot.com/t5/APIs-Integrations/400-Error-on-POST-to-Contacts-API/m-p/664788)”  
Also, I’d love to put you in touch with our Top Experts: Hi @Anton, [@sylvain\_tirreau](https://community.hubspot.com/t5/user/viewprofilepage/user-id/601366) and [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) do you have other suggestions to help @SSun7, please?  
Have a lovely day and thanks so much in advance for your valuable contributions! ❤  
Bérangère

---

<div class="post-metadata">

**Author:** ![sylvain\_tirreau](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sylvain_tirreau/32/67408_2.png) [@sylvain\_tirreau](https://community.hubspot.com/u/sylvain_tirreau)\
**Post date:** [May 6, 2025, 11:17am UTC](https://community.hubspot.com/t/import-api-400-bad-request-no-meaningful-error-message/131080/3 "2025-05-06T11:17:42Z")

</div>

Hi,

Have you installed the form-data module (npm install form-data) that you are using in your script? When attaching the file, specify the name and type. Try something like that:

```lia-code-sample
const FormData = require('form-data');
const formData = new FormData();

const headers = {
 Authorization: `Bearer ${oauthToken.accessToken}`,
 ...formData.getHeaders()
};

formData.append('files', fs.createReadStream(csvPath), {
 filename: 'myfile.csv',
 contentType: 'text/csv'
});

const response = await axios.post(url, formData, { headers });

```

---

<div class="post-metadata">

**Author:** ![SSun7](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@SSun7](https://community.hubspot.com/u/SSun7)\
**Post date:** [May 6, 2025, 2:32pm UTC](https://community.hubspot.com/t/import-api-400-bad-request-no-meaningful-error-message/131080/4 "2025-05-06T14:32:48Z")

</div>

Thank you! This works! I think it’s the headers issue.
