upload file to file manager hubspot api error axios

SOLVE
jeanRoger
Member

keep getting an error while trying to upload a file to hubspot using axios ,

[Error: Error: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 400 Bad Request</title>
</head>
<body><h2>HTTP ERROR 400</h2>
<p>Problem accessing /filemanager/api/v3/files/upload. Reason:
<pre> Bad Request</pre></p>
</body>
</html>

 

tried in postman and its working, my body looks like

const fileOptions = {
access: 'PUBLIC_INDEXABLE',
overwrite: false,
duplicateValidationStrategy: 'NONE',
duplicateValidationScope: 'ENTIRE_PORTAL',
};
const fileParams = {
options: JSON.stringify(fileOptions),
folderPath: 'bills',
};
const body = new FormData();
body.append('file', fs.createReadStream('atest.pdf'));
Object.keys(fileParams).forEach((key) => body.append(key, fileParams[key]));
0 Upvotes
1 Accepted solution

Accepted Solutions
jeanRoger
Solution
Member

Found the solution... it was because my space didn't have access to the filemanager options, after trying with a developer account, I was able to make it work

View solution in original post

0 Upvotes
7 Replies 7
quentin_lamamy
Key Advisor

Hi @jeanRoger 

Can you post a screenshot of your api log, give us the request body and the response body

 

hsSign_smaller.png


0 Upvotes
jeanRoger
Solution
Member

Found the solution... it was because my space didn't have access to the filemanager options, after trying with a developer account, I was able to make it work

View solution in original post

0 Upvotes
selvaadharva
Participant

Hello jeanRoger,

           Even I am trying to upload a file to the Hubspot file manager, but I am not able to upload using postman can you please share your postman  URL and body

0 Upvotes
jeanRoger
Member

Hello @selvaadharva , on postman you have to use formData, so it has to be something like this:

Screen Shot 2020-12-14 at 9.40.58 AM.png

Note: for the file, use the type file 

and for the options object, something like this : 

{"access":"PUBLIC_INDEXABLE","ttl":"P3M","overwrite":false,"duplicateValidationStrategy":"NONE","duplicateValidationScope":"ENTIRE_PORTAL"}
selvaadharva
Participant

Thanks a lot!. It's worked for me...

Sheamus
Participant

This should be filed as a bug with Hubspot.  400 is a bad request. 401 is unauthorized which makes way more sense in this case.

0 Upvotes
Rajkumars
Member

Hello jeanRoger,

            I am trying to upload a file to the Hubspot file manager using java,  can you please share java code?

0 Upvotes