Skip to main content

Notifications

Community site session details
Power Automate - Building Flows
Answered

multipart/form-data

Like (3) ShareShare
ReportReport
Posted on 2 Oct 2024 22:53:48 by 1,084
I have a webhook from an external app.  That is sending files that are submitted.
 
I have a flow
 
I have a trigger in the flow "When an HTTP Request is received"
 
The webhoook sends as "multipart/form-data" type
 
So cant generate a schema, just leave blank.
 
Can't parse json, since not json
 
I can try to do splits, replaces, etc.
But it is very messy and it seems like when you convert to string for the replaces, it changes the base64 content to something else? XML?
 
What is the best way to do this?  Below is an example of what the webhook sends.. the content has been removed from the word document, there will always be 1 resume, 1 aadhar card, 1 pan card but could be multiple pay documents...:
 
{
  "$content-type": "multipart/form-data; boundary=1924ec1e13c",
  "$content": "<CONTENT BASE64>",
  "$multipart": [
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"pancard\"; filename=\"resume.docx\"",
        "Content-Type": "application/x-tika-ooxml",
        "Content-Length": "14777"
      },
      "body": {
        "$content-type": "application/x-tika-ooxml",
        "$content": "<CONTENT BASE64>"
      }
    },
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"aadhardcard\"; filename=\"aadhar.txt\"",
        "Content-Type": "text/plain",
        "Content-Length": "6"
      },
      "body": "aadhar"
    },
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"payslips\"; filename=\"pay2.txt\"",
        "Content-Type": "text/plain",
        "Content-Length": "3"
      },
      "body": "pay"
    },
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"payslips\"; filename=\"pay.txt\"",
        "Content-Type": "text/plain",
        "Content-Length": "3"
      },
      "body": "pay"
    }
  ]
}
 
 
  • Verified answer
    MichaelFP Profile Picture
    1,831 Super User 2025 Season 1 on 03 Oct 2024 at 18:58:32
    multipart/form-data
    Apply the steps below to get each file from multi-part format.
     
    First you need to get muiltpart content. for that you need to use the compose using the following expression
     
    triggerBody()?['$multpart']
     
     
    it will give to you the array of the files, so you will now using apply for each with the result of the compose
     
     
     
    Now you will be able to loop over the files send. So now we will get the binary and the file name
     
    Get the file
     
    Inside the "Apply to each" use the compose action with the following expression:
     
    item()?['body']
     
     
    Get File Name
     
    Inside the "Apply to each" use the compose action with the following expression:
     
    replace(split(split(item()?['headers/Content-Disposition'], 'filename="')[1], '"')[0], '\"', '')
     
     
    and now you can try to receive a new file.
     
    in your flow you will see that you got the file binary and file name
     
     
    Hope that helps you!
     
     
    If my answer helped you, please give me a thumbs up (👍). If solve your question please mark as answer ✔️. This is help the community.
     
     
  • Mattw112b Profile Picture
    1,084 on 03 Oct 2024 at 16:08:41
    multipart/form-data
    So the weird part is, the output of the body of the "When HTTP request is received" trigger, doesn't look anything like the input to the compose directly after it?
     
    So the "$" items above for example arent there.. it looks like this:
     
     
    so can't really remove the "$" and there's no way really to convert this to json.
     
    so then it gets messy trying to split, replace, etc.  on this.  When I try I have to convert to string, then have all these \r\n\r\n characters.. then the base64 gets converted to somethign else ?xml?  
     
     
  • Suggested answer
    MichaelFP Profile Picture
    1,831 Super User 2025 Season 1 on 03 Oct 2024 at 02:33:59
    multipart/form-data
    using the replace to remove "$" and after parse to JSON it will work. Because properties with "$" are internally handle by Power automate. 
     
    you can replace "$" from: $content-type, $multpart,$content, to avoid to remove from a text that has the symbol.
     
    after that you be able to interact with the content.
     
    If my answer helped you, please give me a thumbs up (👍). If solve your question please mark as answer ✔️. This is help the community.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Building Flows

#1
David_MA Profile Picture

David_MA 385 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 318

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 310 Super User 2025 Season 1

Overall leaderboard
Loading started
Loading started