# Insert files by API - Error 400 Bad Request

**URL:** <https://community.hubspot.com/t/insert-files-by-api-error-400-bad-request/68331>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, professional\
**Created:** [November 1, 2022, 4:49pm UTC](https://community.hubspot.com/t/insert-files-by-api-error-400-bad-request/68331 "2022-11-01T16:49:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoseMendes](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/josemendes/32/39641_2.png) [@JoseMendes](https://community.hubspot.com/u/JoseMendes)\
**Post date:** [November 1, 2022, 4:49pm UTC](https://community.hubspot.com/t/insert-files-by-api-error-400-bad-request/68331/1 "2022-11-01T16:49:23Z")

</div>

Hi Community;  
I need to insert files into HubSpot using the API.  
But I get the error message “Error 400 Bad Request”.  
Can you help…  
Code:

---  
curl  
--location --request POST ‘[https://api.hubapi.com/files/v3/files](https://api.hubapi.com/files/v3/files)’ \  
--header ‘content-type: multipart/form-data’ \  
--header ‘Authorization: Bearer xxx-xxx-xxx-xxx-xxx-xxx’ \  
--body  
‘{  
“file”: “[https://ten-my.sharepoint.com/business/turn\_on\_microsoft\_com/docs/tests/pdf\_test.pdf](https://ten-my.sharepoint.com/business/turn_on_microsoft_com/docs/tests/pdf_test.pdf)”,  
“folderPath” : “/newdocs”,  
“folderId”: “3354208876”,  
“options”: {  
“access”: “PRIVATE”,  
“overwrite”: “false”,  
“duplicateValidationStrategy”: “NONE”,  
“duplicateValidationScope”: “EXACT\_FOLDER”  
}  
}’

---

Thank you for your attention.

---

<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:** [November 2, 2022, 5:16pm UTC](https://community.hubspot.com/t/insert-files-by-api-error-400-bad-request/68331/2 "2022-11-02T17:16:45Z")

</div>

Hey, @JoseMendes 👋 Thanks for reaching out. I wonder if this is a case of the documentation being confusing.

Questions:

- In your example, and failed attempts, are you setting **both** the **folderId** and **folderPath** in your request? It looks like it from the above code example and I want to be 100% sure.
- Have you tried sending a request using only the **folderId** _or_ **folderPath**?

I ask because looking at the documentation here — [Files API](https://developers.hubspot.com/docs/api/files/files), the Overview tab has information about this that the endpoint tab does not. Specifically, this part — “`folderId` and `folderPath` cannot be set at the same time.”

 ![cant-do-both.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/e/ee611ced385e0e34b3d095ea0f680854e4646bba.png)

Can you try making a test request and send either only the **folderId** _or_ **folderPath** , but not both, please?

Thank you very much! — Jaycee

---

<div class="post-metadata">

**Author:** ![JoseMendes](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/josemendes/32/39641_2.png) [@JoseMendes](https://community.hubspot.com/u/JoseMendes)\
**Post date:** [December 3, 2022, 3:34pm UTC](https://community.hubspot.com/t/insert-files-by-api-error-400-bad-request/68331/3 "2022-12-03T15:34:18Z")

</div>

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

Works perfectly with this code:  
---

curl  
--location --request POST ‘[https://api.hubapi.com/files/v3/files](https://api.hubapi.com/files/v3/files)’ \  
--header ‘Authorization: Bearer xxx-xxx-xxx-xxx-xxx-xxx’ \  
--form ‘“[https://ten-my.sharepoint.com/business/turn\_on\_microsoft\_com/docs/tests/pdf\_test.pdf](https://ten-my.sharepoint.com/business/turn_on_microsoft_com/docs/tests/pdf_test.pdf)”’ \  
--form ‘folderPath=“/newdocs”’ \  
--form ‘options=“{\“access\”: \“PRIVATE\”,  
\“overwrite\”: \“false\”,  
\“duplicateValidationStrategy\”: \“NONE\”,  
\“duplicateValidationScope\”: \“EXACT\_FOLDER\”}”’

---

Thank`s for tour help.
