How to post multipart/form-data using http connector in Power Automate?
Use Case
Last week, I spent a lot of efforts in calling HTTP request from external or 3rd party system. While working on it I face challenges with passing the file content. There is not much documentation available on handling this scenario so I thought of documenting the steps to pass form/data with file in http request.
Scenario
We need to call a rest endpoint that accepts multipart/form-data. Basically, it is an email with some text fields like subject, body etc. along with an attachment. The purpose of sending the attachment of file is to extract the data from file content by external system that internally uses AI model.

Solution
1.Add “Get file content” to get the content of file that needs to send as an attachment. Please make sure that you set the ‘Infer Content Type’ parameter to ‘Yes’. In this example, I have hard coded the file path but you could pass it dynamically as per the need:

2. Next, add “Compose” that will hold the double quotation which will be needed when we create the request body in http action. I have taken this step as I have observed that sometimes http request fails because of incorrect JSON. So, added this step to avoid this scenarios:

Input value in compose action:
"
3. Finally, add “Http” action to call the rest endpoint. Set the Method & URI parameter. In the body, we will create a JSON code.
Each parameter has 2 parts: header & body. The header contains the name of the parameter and body contains the value of that parameter.

In case of file parameter, we need to additionally pass the file name.

I have used rand function for the ID to get random number and set the file name as current utc time stamp using utcNow function. But you can modify all those parameters as per the requirements.
The JSON code in the request body looks like:
{
"$content-type": "multipart/form-data",
"$multipart": [
{
"headers": {
"Content-Disposition": "form-data; name=@{outputs('Compose')}uniqueIncEmailId@{outputs('Compose')}"
},
"body": "@{rand(1,1000)}"
},
{
"headers": {
"Content-Disposition": "form-data; name=@{outputs('Compose')}emailSubject@{outputs('Compose')}"
},
"body": "test subject"
},
{
"headers": {
"Content-Disposition": "form-data; name=@{outputs('Compose')}emailBody@{outputs('Compose')}"
},
"body": "test email body"
},
{
"headers": {
"Content-Disposition": "form-data; name=@{outputs('Compose')}tokenId@{outputs('Compose')}"
},
"body": "xxxxx-token id-xxxxx"
},
{
"headers": {
"Content-Disposition": "form-data; name=@{outputs('Compose')}Attachment1@{outputs('Compose')}; filename=@{utcNow('yyyyMMddHHmmss')}.pdf@{outputs('Compose')}"
},
"body": @{body('Get_file_content')}
}
]
}
Please note that you should place your file in SharePoint library or one drive before passing the content in the body of the parameter. As when we get the file from SharePoint or one drive, we would get the content type along with content bytes.
Output
Output of Http action:

Conclusion
Through this example, we have seen the technique of passing the header & body of each parameter when calling multipart form/data request.
Hire Me for Power Automate Consulting
I offer expert Power Automate consulting at $50/hour with a minimum booking of 10 hours. If you’re looking to streamline workflows or automate business processes, I’d love to help.
📩 Message me on LinkedIn to reserve your slot.
Saket Pandey
Thanks for the article, it was very useful..!!
I am trying to upload a .msg/.eml file using the same setup. It shows that file has been corrupted. Do we need to do some additional handling like base64 to binary conversion..?
Manish Solanki
Hi Sanket,
Pls try to create a custom object in body of http action for input file parameter. In ‘$content-type’ property enter the static text as the mime type of .msg/eml file. In second parameter ‘$content’, pass the output of $content property value (base64 string) from the body of get file action.
The file object should look like this:
{
“$content-type”: “[mime type of .msg/eml file]”,
“$content”: “[dynamic base64 string of file content]”
}
Thanks
Jaersi
Have you solved the problem of uploading msg files? I used the following structure but it still shows that the file is corrupted:
{
“$multipart”: [
{
“headers”: {
“Content-Disposition”: “form-data; name=\”file\”; filename=\”@{triggerBody()[‘file’][‘name’]}\””,
“Content-Type”: “application/vnd.ms-outlook”
},
“body”: “@{base64ToBinary(triggerBody()[‘file’][‘contentBytes’])}”
},
{
“headers”: {
“Content-Disposition”: “form-data; name=\”bbb\””
},
“body”: “@{triggerBody()[‘number_1’]}”
},
{
“headers”: {
“Content-Disposition”: “form-data; name=\”a\””
},
“body”: “@{triggerBody()[‘text’]}”
},
{
“headers”: {
“Content-Disposition”: “form-data; name=\”xxx\””
},
“body”: “@{triggerBody()[‘number’]}”
}
],
“$content-type”: “multipart/form-data”
}
Manish Solanki
Hi Jaersi,
Pls try 2 methods to resolve the file corrupted issue:
1. In file body input property just pass the file object from the trigger: “body”: “@{triggerBody()?[‘file’]}”
2. If first option does not work then don’t convert base64 to binary as contentbytes of the file object is as a base64 string. Remove “base64ToBinary” function in the expression, just directly pass the base64 string value: “body”: “@{triggerBody()?[‘file’]?[‘contentBytes’]}”
Hope that one of those tricks will resolve the issue 🙂
Thank you!
Jaersi
Hi Manish,
First off, thank you so much for your advice! Your suggestions have truly sparked some great problem-solving ideas, and I can’t tell you how helpful they’ve been! 😊 I’m still running into upload issues, though, so I wanted to share the specifics in case you have any further insights!
1. Regarding .msg file uploads:
I tried passing the trigger’s file object directly, but the system still can’t read the file correctly. Here’s a head-scratcher I noticed when checking backend data:
When sending via Postman, the backend receives the file as 6,339,584 bytes.
When using Power Automate’s HTTP action with form-data, the backend reports it as 1,902,700 bytes.
Do you think this could be a platform limitation on file size or formatting?
2. Another upload hiccup with document types:
Power Automate successfully uploads .doc files via HTTP, but .docx files keep showing as “corrupted.” I’ve tested these content types:
application/vnd.openxmlformats-officedocument.wordprocessingml.document (for .docx),
application/msword (for .doc).
Strangely, only .doc works. Could the platform be missing some configuration for .docx files? I’d be grateful for any thoughts on this!😊
Manish Solanki
I appreciate you liked this blog and found it useful!
I would suggest creating a new test cloud flow. Instead of passing file object via input parameter from the manual trigger use a SharePoint library to fetch the file object (using ‘get file content’ or ‘get file content by path’ action). Also in my article, I passed the file object reading file from a SharePoint site to the http action.
Please try that method once. If that works then we will compare the file object (mime type, content bytes etc.).
Thank you!
Naresh
Thanks Manish. Your article has really helped me to solve the problem of creating a custom connector to upload file using custom API. You saved my day.
Fagner Fernandes Douetts
I’m trying to upload an image in PNG format the same way it was taught above, but I’m not succeeding. It returns a TXT file with the same information I provided and the file in Base64.
———————————————-
my request in postman is working:
https://dl.imgdrop.io/file/aed8b140-8472-4813-922b-7ce35ef93c9e/2025/04/02/Captura-de-tela-2025-04-02-135049a31b6f91d348be06.png
——————————————–
body send:
{
“$content-type”: “multipart/form-data”,
“$multipart”: [
{
“headers”: {
“Content-Disposition”: “form-data; name=\”tipoDocumento\””
},
“body”: “OFC”
},
{
“headers”: {
“Content-Disposition”: “form-data; name=\”cpfCnpj\””
},
“body”: “05412518133”
},
{
“headers”: {
“Content-Disposition”: “form-data; name=\”idOrigem\””
},
“body”: “COECSH-1001-2025”
},
{
“headers”: {
“Content-Disposition”: “form-data; name=\”nomeTagSistema\””
},
“body”: “PWAUTOMATE”
},
{
“headers”: {
“Content-Disposition”: “form-data; name=\”file\”; filename=\”Controls.png\””
},
“body”: “@{body(‘Get_file_content_using_path’)}”
}
]
}
Manish Solanki
In the flow run, pls verify the input file object of http action. It should have 2 properties: mime type & base64 content in the format:
{
“$content-type”: “[mime type png file]”,
“$content”: “[base64 string of file content]”
}
You may also verify the output of ‘Get file content by path’ action. It should have a proper mime type and content properties as per the above schema.
Thank you!
G
Is it possible to send a pdf via postman without storing it in sharepoint ?
I just want to read an attachment which I receive via json, and then process it.
Kyle
Hi,
I need to send an API request how to I go about doing it for an object. Below is sample data and the Work_order_Contract is an object. I got the Project_id and Attachment working looking how to format to get Work_order_Contract as it is required by the API.
{
“project_id”: 42,
“attachments”: [
“string”
],
“work_order_contract”: {
“accounting_method”: “amount”,
“actual_completion_date”: “2012-10-27”,
“approval_letter_date”: “2012-10-23”,
“contract_date”: “2012-10-23”,
“contract_estimated_completion_date”: “2012-10-31”,
“contract_start_date”: “2012-10-03”,
“description”: “Paving level 3 parking lot.”
}
}
Manish Solanki
Hi,
Are you saying you need to pass JSON object as a parameter in multi/part form data http call? I would suggest to first test in the postman and take reference to set parameters values in power automate cloud flow. If you are still facing issue, I will be happy to jump over a teams call & try to solve the issue.
Thank you!