web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Excel file from email ...
Power Automate
Unanswered

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,129 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard