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 / Excel file from email ...
Power Automate
Suggested Answer

Excel file from email attachment to a POST API request

(0) ShareShare
ReportReport
Posted on by 2

Goal:

I want to create a Power Automate flow that:

  1. Triggers when a new email arrives in a shared mailbox (including attachments).
  2. Loops through each attachment and checks if the file extension is .xlsx.
  3. Sends the file in a POST request to an API that works correctly when tested in Postman.

Problem:

Even though my email trigger has "Include Attachments" enabled, I cannot correctly send the file content in the HTTP POST request. My API either rejects the file or does not receive it in the correct format.

Current Setup:

 
​​​​​​​
  • Trigger: "When a new email arrives (V3)"
    • Include Attachments: Yes
  • Apply to each (Attachments)
    • Condition: Attachments Name ends with .xlsx
    • HTTP POST Request (multipart/form-data):
       
      json
      {
      "$content-type": "multipart/form-data; boundary=--------------------------208446390803225736562660",
      "$multipart": [
      {
      "headers": {
      "Content-Disposition": "form-data; name=\"file\"; filename=\"@{items('Apply_to_each')?['Name']}\"",
      "Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
      },
      "body": {
      "$content-type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
      "$content": "@{base64(items('Apply_to_each')?['ContentBytes'])}"
      }
      }
      ]
      }

 

What I've Tried:

  1. ✅ Confirmed my API works in Postman (it correctly processes .xlsx files).
  2. ✅ Copied the request body sent through the postman call (except for dynamic content of course)
  3. ✅ Checked that attachments are included in the trigger.
  4. ❌ No matter how I format the request, the API either does not receive the file correctly and returns nothing to process as it could not read it.

Question:

  • How should I correctly format the HTTP request body in Power Automate to send the .xlsx file as a valid multipart/form-data attachment?
  • More specifically, what should be the value of $content ?
  • Do I need to manually convert the file to base64 or send it as raw binary?

Thanks in advance for any help!

Categories:
I have the same question (0)
  • Suggested answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at
     
    Already the content attribute is in base64 format- hence no need to convert it to base64 again, But i would recommend if you can try this - 
    before calling http request - use get attachment action to get the email attachment content and use its content output in the http request action - see whether that works for you ?
     
     

    Thanks & Regards,
    Nived N

    Stay connected:
    LinkedIn | YouTube | Blogs

    Was this answer helpful?
    If yes, please mark it as the solution by selecting the checkbox in the discussion thread.
    Your feedback motivates me to keep contributing. Thank you!

  • JL-11020037-0 Profile Picture
    2 on at
     
    Thank you for your reply.
     
    What attachment id should I select in the Get Attachment action ? I'm struggling to find the right one.
     
    I tried using the following: 



    But here's the result after testing the flow:
     
     
     
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 976

#2
Valantis Profile Picture

Valantis 863

#3
Haque Profile Picture

Haque 547

Last 30 days Overall leaderboard