'How can I send documents with http request to power automate?

How can I send array documents and images with an HTTP request to power automate?

I am using type script with nodejs as backend.

Please see the code I am using below:

Services.ts:

sendEmailData(   Notice_ID: string, Site_Notice_ID: string,EmailAddress: 
string,Issued_To: string,Issue_To_Email: string,Description: string,Documents: any){

   const postData: Post = {Notice_ID:Notice_ID, Site_Notice_ID: 
 Site_Notice_ID,EmailAddress: EmailAddress,Issued_To:Issued_To,
 Issue_To_Email: Issue_To_Email,Description:Description, Documents: Documents};

  this.http.post(this.SendEmailUrl, postData).subscribe(responseData => {
console.log(responseData)

  });


}

Component.ts:

sendEmail(){
//   console.log(emailData)

let Description = (document.getElementById("input2") as HTMLInputElement).value
this.postsService.sendEmailData(
  emailData.Notice_ID,
  emailData.Site_Notice_ID,
  emailData.EmailAddress,
  emailData.Issued_To,
  emailData.Issue_To_Email,
  Description,
  this.Documents)

}

Power automate HTTP received sample:

{
  "Notice_ID": "39208101",
  "Site_Notice_ID": "392081",
  "EmailAddress": "[email protected]",
  "Issued_To": "Jay",
  "Issue_To_Email": "[email protected]",
  "Description": "",
  "Documents": [
    {},
    {},
    {}
  ]
}


Solution 1:[1]

You wanna send documents to PWA flow, right? What is the origin format and what format do you want to save these documents in? Where do you want to save them?

I'm considering you want to send them to PWA by a post request and save it in a OneDrive Business' folder.

    {
    "Notice_ID": "39208101",
    "Site_Notice_ID": "392081",
    "EmailAddress": "[email protected]",
    "Issued_To": "Jay",
    "Issue_To_Email": "[email protected]",
    "Description": "",
    "Documents": [ {"$content-type":"application/pdf","$content":"your base64 encoded 
    file here"}]
     }

You can take a look at the complete example: https://api.npoint.io/073b1351d9b0cd0c7f88

Then, add the key "Documents" to a variable, like this: enter image description here

Create an "apply to each" action to run your "documents" list.

For each dictionary in your document list, create a file: enter image description here

In the "file content" field you can put the "Current action" variable.

Don't forget to create a counter or find some other way to name your created files with different names. You can also bring them named from your application and use the JSON body below:

"Documents": [ {"filename":"myfile.pdf","file":{"$content- 
type":"application/pdf","$content":"your base64 encoded 
file here"}}]

And set the filename in the "Apply to each": enter image description here

Change the "file content": enter image description here

You can use this website for generating base64 encoded files for testing your flow: https://base64.guru/converter/encode/pdf

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cigien