# Uploading a file using Power Automate

**URL:** <https://community.hubspot.com/t/uploading-a-file-using-power-automate/87129>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, professional\
**Created:** [August 9, 2023, 3:19pm UTC](https://community.hubspot.com/t/uploading-a-file-using-power-automate/87129 "2023-08-09T15:19:59Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![AKhan786](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@AKhan786](https://community.hubspot.com/u/AKhan786)\
**Post date:** [August 11, 2023, 2:29pm UTC](https://community.hubspot.com/t/uploading-a-file-using-power-automate/87129/6 "2023-08-11T14:29:12Z")

</div>

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:

1. 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!

2. The file content needs to be converted from Base64 (or whatever format you might have gotten it in) into Binary.

This is what the request looks like:

 ![AKhan786_0-1691764011373.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/5/5f4eaaacc11731c682394f7118bccdb01c9c15e7.png)

And this is the code for copy/paste:

(Bear in mind the file body is dynamic content so you’d replace that with your binary file data)

```lia-code-sample
{
"$content-type": "multipart/form-data",
"$multipart": [
{
"headers": {
 "Content-Disposition": "form-data; name=\"options\""
 },
 "body": "{\"access\": \"PRIVATE\"}"
},
 {
 "headers": {
 "Content-Disposition": "form-data; name=\"file\"; fileName=\"Test.pdf\""
 },
 "body": @{base64ToBinary(outputs('Get_file_content')?['body']?['$content'])}
 },
 {
 "headers": {
 "Content-Disposition": "form-data; name=\"folderPath\""
 },
 "body": "/Uploaded Documents"
 }
 ]
}

```

---

_[View the full topic](https://community.hubspot.com/t/uploading-a-file-using-power-automate/87129)._
