# 400 Error on POST to Contacts API

**URL:** <https://community.hubspot.com/t/400-error-on-post-to-contacts-api/60931>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [July 13, 2022, 9:09pm UTC](https://community.hubspot.com/t/400-error-on-post-to-contacts-api/60931 "2022-07-13T21:09:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DMesser](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dmesser/32/50623_2.png) [@DMesser](https://community.hubspot.com/u/DMesser)\
**Post date:** [July 13, 2022, 9:09pm UTC](https://community.hubspot.com/t/400-error-on-post-to-contacts-api/60931/1 "2022-07-13T21:09:08Z")

</div>

Hello!

We are trying to use the Contacts API to bulk import contacts from a CSV but we are having a bit of trouble. I created a test .csv file to try in a sandbox account with and followed the Contacts API article. Below I’ve included my request:

```lia-code-sample
function submitHubSpotImport() {
 const url = 'https://api.hubapi.com/crm/v3/imports?hapikey=xxx'; 

 const body = {
 "name": "test_import",
 "files": [{
 "filename": "test-contact-import-new.csv",
 "fileFormat": "CSV",
 "dateFormat": "DAY_MONTH_YEAR",
 "fileImportPage": {
 "hasHeader": true,
 "columnMappings": [
 {
 "columnObjectTypeId": "0-1",
 "columnName": "First Name",
 "propertyName": "firstname",
 "idColumnType": null
 },
 {
 "columnObjectTypeId": "0-1",
 "columnName": "Last Name",
 "propertyName": "lastname",
 "idColumnType": null
 },
 {
 "columnObjectTypeId": "0-1",
 "columnName": "Email",
 "propertyName": "email",
 "idColumnType": null
 },
 ]
 }
 }]
 };

 var request = {
 method: 'POST',
 headers: {
 'Content-Type': 'multipart/form-data'
 },
 body: JSON.stringify(body)
 };

 fetch(url, request)
 .then(function() {
 console.log('Success: ' + request);
 })
 .catch(function(err) {
 console.log('Error: ' + err);
 });
}

```

This returns a 400 error.

In postman I get the same 400 error but a bit more info:

```lia-code-sample
{
 "status": "error",
 "message": "Import cannot be processed without file data!",
 "correlationId": "xxx",
 "category": "VALIDATION_ERROR"
}

```

I do have the file key in postman pointing to the file I’m trying to use. Seems as if for some reason the file isn’t coming through? I also tried including the full url to the file in the filename after I uploaded it to our file manager but that didn’t seem to help. My test csv looks like this:

I can provide any further information needed. Any help would be greatly appreciated! Thank you.

---

<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:** [July 14, 2022, 10:44pm UTC](https://community.hubspot.com/t/400-error-on-post-to-contacts-api/60931/2 "2022-07-14T22:44:45Z")

</div>

Hey, @DMesser 👋 Thanks for the great question. The bad news, I cannot reproduce your error. The good news is I followed the same example you provided and received a successful response using Postman.

Here’s what I did:

- I used this example — [Start an import](https://developers.hubspot.com/docs/api/crm/imports#:~:text=in%20HubSpot.-,Start%20an%20import,-You%20can%20start) CRM Bulk Import API

- I used this endpoint`POST /crm/v3/imports/​`

- I set my headers included`Content-Type multipart/form-data​`  
 ![content-type.png](https://d2qpr2jzcazej7.cloudfront.net/optimized/3X/1/a/1aa783f5c77f2b4be4e3e8c1b9770fee15b6c827_2_690x28.png)

- I set my Body using the JSON from the example and the CSV from my desktop

 ![body-as-form-data.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/b/b543a0b0f92c8a29c8ebd994b990d4699a9c9dfa.png)

- Which returns a HTTP 200 status and a`"state":"DONE"​`
- Using`GET crm/v3/imports/{importId}​`I can verify the import as done

The one issue I had was needing to set the “type” for my Key “files” to “file” instead of “text” so the file would attach correctly.

 ![file-as-file.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/a/f/af1a6d5b54ef2d0cd75bbec625978f383b1b0c34.png)

I hope this helps get you moving forward.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![Faizan\_32](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Faizan\_32](https://community.hubspot.com/u/Faizan_32)\
**Post date:** [November 12, 2023, 7:36am UTC](https://community.hubspot.com/t/400-error-on-post-to-contacts-api/60931/3 "2023-11-12T07:36:16Z")

</div>

Im working with REST API to perform a posting import using a csv file  
Ive got alot of columns but im posting 2 of them below just for a sample as im facing the same issue and i tried your instructions but i couldnt get a positive response and still getting this error : “{“status”:“error”,“message”:“Import cannot be processed without file data!”,“correlationId”:“5ccb9a7e-c439-4a87-b4dc-729e7ee3b4ca”,“category”:“VALIDATION\_ERROR”}”  
Here is my sample json object :

payload = {‘importRequest’: '{

“name”: “Opportunity Posting Import”,

“files”: [

{

“filename”: “temp\_opportunity\_data.csv”,

“fileFormat”: “CSV”,

“dateFormat”: “DAY\_MONTH\_YEAR”,

“fileImportPage”: {

“hasHeader”: true,

“columnMappings”: [

{

“columnName”: “opportunities.id”,

“propertyName”: “opportunities.id”,

“idColumnType”: “Postings”

},

{

“columnName”: “Posting\_Locations”,

“propertyName”: “Posting\_Locations”,

“idColumnType”: “Postings”

}

]

}

}

]

}

'}

---

<div class="post-metadata">

**Author:** ![DMesser](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dmesser/32/50623_2.png) [@DMesser](https://community.hubspot.com/u/DMesser)\
**Post date:** [July 15, 2022, 4:50pm UTC](https://community.hubspot.com/t/400-error-on-post-to-contacts-api/60931/4 "2022-07-15T16:50:13Z")

</div>

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

Once I changed the file keyname to files this is all working in postman now. Thank you for your help!

---

<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:** [July 15, 2022, 5:02pm UTC](https://community.hubspot.com/t/400-error-on-post-to-contacts-api/60931/5 "2022-07-15T17:02:45Z")

</div>

Thanks for letting us know, @DMesser 🙌 — Jaycee
