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,082
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.
     
     

Helpful resources

Quick Links

🌸 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…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 101

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 82 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 60 Super User 2025 Season 1

Overall leaderboard