web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to use HTTP action...
Power Automate
Suggested Answer

How to use HTTP action in Power Automate with multipart/form-data (file upload + schema parameter)?

(0) ShareShare
ReportReport
Posted on by

Hi Team,

I’m trying to implement an HTTP action in Power Automate to send a request with multipart/form-data, where I need to:


  • Upload a file attachment

  • Pass additional parameters (e.g., schema name or metadata fields)

  •  

Requirement:

I need to call an API endpoint that expects:


  • Content-Type: multipart/form-data

  • One part: file (binary content)

  • Other parts: form fields (like schemaName, etc.)

  •  

What I have tried:

 

I attempted using the HTTP action with custom headers and body, but I’m facing issues with:

 

  • Correct formatting of multipart boundary

  • Passing file content correctly from Power Automate trigger/output

  • Combining file and form parameters in the same request





  •  
  •  
  •  
  •  
 

Example requirement:

 

Something like:

 
--PowerAutomateBoundary
Content-Disposition: form-data; name="schemaName" 

schema1
--PowerAutomateBoundary
Content-Disposition: form-data; name="File"; filename="@{triggerBody()?['fileRecord']?['name']}"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

@{triggerBody()?['file']?['contentBytes']}
--PowerAutomateBoundary--
 

Questions:

 

  1. How can we properly construct multipart/form-data body in Power Automate HTTP action?

  2. What is the correct way to attach file content (binary) from trigger or previous step?

  3. Is there any recommended approach or workaround (like connector, Azure Function, etc.) for this scenario?





  4.  
  5.  
  6.  
  7.  
 

Any working example or guidance would be really helpful.

 

Thanks in advance!

Power Automate Er...
error .png

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Suggested answer
    Assisted by AI
    sannavajjala87 Profile Picture
    388 Super User 2026 Season 1 on at
    Hi,
    Yes, this can be done, but multipart/form-data is a little tricky in Power Automate because the HTTP action does not automatically build the multipart body for you.
    A few things to check:
    1. Do not manually set only Content-Type: multipart/form-data without a boundary. The boundary in the header must match the boundary used in the body.
    Example header:
    Content-Type: multipart/form-data; boundary=PowerAutomateBoundary
    1. The body needs to include each form part correctly, including line breaks between headers and values.
    Example structure:
    --PowerAutomateBoundary
    Content-Disposition: form-data; name="schemaName"

    schema1
    --PowerAutomateBoundary
    Content-Disposition: form-data; name="file"; filename="test.xlsx"
    Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

    [file content here]
    --PowerAutomateBoundary--
    1. For the file content, make sure you are using the actual file content from a previous action, such as SharePoint Get file content or OneDrive Get file content, not just the file metadata/name.
    That said, sending binary files through a manually constructed multipart body can be unreliable in Power Automate, especially if the file content is base64 encoded or treated as text.
    The more reliable approach is usually one of these:
    • Use a custom connector with a properly defined OpenAPI schema for multipart upload
    • Use an Azure Function as a wrapper API, where Power Automate sends JSON/base64 and the Azure Function converts it to multipart/form-data
    • If the target API supports it, send the file as base64 JSON instead of multipart/form-data
    My recommendation would be to avoid manually building multipart/form-data in the HTTP action unless the payload is very small and simple. For production use, an Azure Function or custom connector wrapper is usually much easier to support and troubleshoot.
    Hope this helps.
     
  • Suggested answer
    Sam_Fawzi Profile Picture
    915 Super User 2026 Season 1 on at
     
    The reason the manual approach keeps failing is that the HTTP action's body is a string, so when you paste contentBytes (base64) into it, you're sending base64 text between the boundaries — not the actual file bytes. The API receives a corrupted file.
    The fix is to let the HTTP action build the multipart body for you using its native $multipart schema. Set the HTTP action's body to this:
    {
      "$content-type": "multipart/form-data",
      "$multipart": [
        {
          "headers": {
            "Content-Disposition": "form-data; name=\"schemaName\""
          },
          "body": "schema1"
        },
        {
          "headers": {
            "Content-Disposition": "form-data; name=\"file\"; filename=\"@{triggerBody()?['fileRecord']?['name']}\"",
            "Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
          },
          "body": {
            "$content-type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "$content": "@{triggerBody()?['file']?['contentBytes']}"
          }
        }
      ]
    }
    Two important points:
    • The file part's body is an object with $content-type and $content. When Power Automate sees base64 in $content, it decodes it back to raw binary before sending — which is exactly what the manual string approach can't do.
    • Don't set the Content-Type: multipart/form-data header yourself. Let the action generate the boundary automatically. Setting it manually is what causes the boundary mismatch.
    One note: this JSON body form isn't shown in the visual designer, so you may need to enter it via the code/expression view. It also requires the premium HTTP action.

    Hope this helps!
  • Suggested answer
    Vish WR Profile Picture
    3,730 on at

    The issue occurs because the HTTP action body is treated as a plain string. When contentBytes (Base64) is pasted into the multipart body, the API receives Base64 text instead of the actual binary file, resulting in a corrupted upload.


    Instead, use the HTTP action’s native $multipart schema, which automatically converts the Base64 content back to binary before sending. Also, do not manually set the Content-Type: multipart/form-data header—Power Automate generates the correct boundary automatically.

     
    {
      "$content-type": "multipart/form-data",
      "$multipart": [
        {
          "headers": {
            "Content-Disposition": "form-data; name=\"schemaName\""
          },
          "body": "schema1"
        },
        {
          "headers": {
            "Content-Disposition": "form-data; name=\"file\"; filename=\"@{triggerBody()?['fileRecord']?['name']}\"",
            "Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
          },
          "body": {
            "$content-type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "$content": "@{triggerBody()?['file']?['contentBytes']}"
          }
        }
      ]
    }
     

    Note: This JSON format may need to be entered using the action’s code/peek view, and it requires the Premium HTTP action.



     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 481

#2
11manish Profile Picture

11manish 278

#3
David_MA Profile Picture

David_MA 276 Super User 2026 Season 1

Last 30 days Overall leaderboard