Insert files by API - Error 400 Bad Request

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’ \
--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”,
“folderPath” : “/newdocs”,
“folderId”: “3354208876”,
“options”: {
“access”: “PRIVATE”,
“overwrite”: “false”,
“duplicateValidationStrategy”: “NONE”,
“duplicateValidationScope”: “EXACT_FOLDER”
}
}’

---

Thank you for your attention.

Hey, @JoseMendes :waving_hand: 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, 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.”

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

Thank you very much! — Jaycee

Hi @Jaycee_Lewis ;

Works perfectly with this code:
---

curl
--location --request POST ‘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”’ \
--form ‘folderPath=“/newdocs”’ \
--form ‘options=“{\“access\”: \“PRIVATE\”,
\“overwrite\”: \“false\”,
\“duplicateValidationStrategy\”: \“NONE\”,
\“duplicateValidationScope\”: \“EXACT_FOLDER\”}”’

---

Thank`s for tour help.