I have files stored in a SharePoint library, and want to use Power Automate ¶ to upload them to HubSpot. I can’t use the async import from URL API as these would be sensitive files.
I’ve checked all the other posts I could find with people experiencing similar issues and can’t seem to get it to work…One person posted their Powershell code and even replicating that resulted in the same error:
Is it the charsetHunch that I’m not setting properly? I’m stumped…and I must say, the documentation is relly not helpfull at all CMS API | Files (hubspot.com) No example is provided, doesn’t say which params are necessary for the upload file endpoint, and isn’t sufficiently explanatory at all
I think the issue is to do with the “Content-Type” header. Regardless of whether you are using the legacy endpoint or the newer endpoint the correct header to use is “multipart/form-data” vs “application/pdf” which you seem to be referencing.
I found this post on the PowerAutomate Community discussing how to POST files with multipart/form-data. It’s not specific to HubSpot but it might help in terms of how the HTTP request was configured.
From what I can see your request looks fine and should work. I think the issue might be how the HTTP module in PowerAutomate is processing the file and hence the 400 error being returned.
Hallelujah! You pointed me on the right path, and after a lot more googling along that line, trial & error testing, I stumbled accross the answer
The key things are:
Format the request body as a multi-part form.
It’s confusing and complex, and I don’t fully understand (like why certain things like the fileName works in the header, but folderPath needs to be in the body) but hey - it works!
The file content needs to be converted from Base64 (or whatever format you might have gotten it in) into Binary.