Skip to main content
Community site session details

Community site session details

Session Id : 62UV79QmEAurhq4Pni6EGp
Power Automate - Using Flows
Answered

what after "When a http request is received" multipart/form-data

Like (0) ShareShare
ReportReport
Posted on 6 Oct 2022 16:51:42 by 30

Good Day everyone,
I m building a react form with multiple files input field and some other basic fields (FirstName, LastName, Email,....). I could Post this data when the form is submitted as multipart/form-data to "When a http request is received" trigger, but not sure how to handle the output so it can be readable and send it via email and attach the files to the email too.
Any help would be appreciated!
Thanks in Advance!

  • Expiscornovus Profile Picture
    32,155 Most Valuable Professional on 17 Oct 2022 at 16:15:35
    Re: what after "When a http request is received" multipart/form-data

    Hi @MartinaRizk,

     

    Thanks for sharing and great to see you figured it out 🙂

  • Verified answer
    MartinaRizk Profile Picture
    30 on 17 Oct 2022 at 16:10:05
    Re: what after "When a http request is received" multipart/form-data

    Hello Everyone,
    for the future viewers, I could find the solution for my scenario. so here it is:
    I m creating a react form where the user will submit it with attached files - I don't know how many files - and need to upload these files to OneDrive and have them attached to email that'll be sent to the submitter, so in react:

     

    const formdata = new FormData(event.target);
    formdata.set('files', uploadedFiles.length); // numbers of files
    
    uploadedFiles.forEach((file, index) => { // uploadedFiles comes from a function that handels the input type="file"
     formdata.append('filename_'+index, file.name);
     formdata.append('file_'+index, file);
    });
    axios({
     method: "post",
     url: the-post-link-you-get-from-when a HTTP Request is Received-flow,
     data: formdata,
     headers: { "Content-Type": "multipart/form-data" },
    })
     .then(function (response) { //handle success
     console.log("New Post has been sent to Power Automate!");
     })
     .catch(function (response) { //handle error
     console.log('error: '+response);
     });

     

     

    and in Power automate:

    note: what's surrounded with red line, is just to show the expression.

    MartinaRizk_2-1666020379388.png

    next add Do Until flow:

    count = variable('count')

    Outputs = Outputs('Compose_-_Total_Files')

    MartinaRizk_3-1666020512701.png

    and here are the flows inside Do Until:

    MartinaRizk_4-1666020961765.png

    this is how the array should look like to set to the attachment field in send email flow later.

    { "Name": triggerFormDataValue(Outputs('Compose_-_filename_x')),

      "ContentBytes": triggerFormDataValue(Outputs('Compose_-_file_x')) }

    MartinaRizk_5-1666021717087.png

    File Name: triggerFormDataValue(Outputs('Compose_-_filename_x'))

    File Content: triggerFormDataValue(Outputs('Compose_-_file_x'))

    MartinaRizk_1-1666023167676.png

    then outside the Do until add Send an Email (V2), and expand the Show Advanced Options, and in the attachment set the array of the files that we created before (you need to switch the button beside the attachment from text to this one): 

    MartinaRizk_0-1666022982868.png

     

     

     

     

     

  • MartinaRizk Profile Picture
    30 on 13 Oct 2022 at 15:05:36
    Re: what after "When a http request is received" multipart/form-data

    Hi @Expiscornovus ,

    I've tried these functions you suggested with a compose flow with inputs (trigger()?['first-name'], triggerBody()?['first-name'], triggerOutputs()?['first-name']) but their outputs was empty, just triggerFormDataValue('first-name') that works for me!

  • Expiscornovus Profile Picture
    32,155 Most Valuable Professional on 13 Oct 2022 at 13:16:03
    Re: what after "When a http request is received" multipart/form-data

    Hi @MartinaRizk,

     

    That is an interesting scenario. What do you see when you use either the trigger, triggerBody or triggerOutputs function instead?

  • MartinaRizk Profile Picture
    30 on 12 Oct 2022 at 19:24:45
    Re: what after "When a http request is received" multipart/form-data

    I used triggerFormDataValue('file_0') from the second link, and it works fine for me. but now my problem that the user can attach many files which I need to loop through them and attach them to the email. how I can dynamically do that?!
    note: I can send the how many files I have for this submission on the post request, so the data would be something like that

    [

      "files": 2,  // total number of attached files

      "filename_0": file_name,

      "file_0": file_content,

      "filename_1": file_name,

      "file_1": file_content

    ]

  • MartinaRizk Profile Picture
    30 on 11 Oct 2022 at 15:30:09
    Re: what after "When a http request is received" multipart/form-data

    Thanks so much @Expiscornovus for your reply and the sources you shared are amazing. im gonna try them out!

     

  • Expiscornovus Profile Picture
    32,155 Most Valuable Professional on 07 Oct 2022 at 13:41:27
    Re: what after "When a http request is received" multipart/form-data

    Hi @MartinaRizk,

     

    I would suggest to have a look at the triggerMultipartBody and triggerFormDataValue functions. Those might be useful to handle the output of your trigger action.

     

    Below are a couple of links with examples

    https://powerusers.microsoft.com/t5/Building-Flows/Working-with-multipart-form-data-from-HTTP-trigger/td-p/594051

    https://siddiquemahsud.blogspot.com/2022/06/upload-file-to-sharepoint-document.html

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

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

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1

Featured topics

Restore a deleted flow