Skip to main content

Notifications

Community site session details

Community site session details

Session Id : oGG6boUt3f/QHEkvj3rvuj
Power Automate - AI Builder
Suggested answer

Power Automate doesn't save attachments correctly

Like (2) ShareShare
ReportReport
Posted on 23 Aug 2024 19:59:06 by 4
Hi,
 
I used a template to save attachments when an e-mail arrives to an specific folder in OneDrive, so far that works, but files are corrupted, doesn't matter the type (pdf, excel file, jpg, etc.).
 
Here is the code.
{

  "type": "OpenApiConnection",

  "inputs": {

    "parameters": {

      "folderPath": "/",

      "name": "@items('Apply_to_each_attachment_from_specific_user')?['name']",

      "body": "@items('Apply_to_each_attachment_from_specific_user')?['contentBytes']"

    },

    "host": {

      "apiId": "/providers/Microsoft.PowerApps/apis/shared_onedriveforbusiness",

      "connection": "shared_onedriveforbusiness",

      "operationId": "CreateFile"

    }

  },

  "runtimeConfiguration": {

    "contentTransfer": {

      "transferMode": "Chunked"

    }

  },

  "metadata": {

    "operationMetadataId": "3c78f01d-b520-47ef-872b-acad8fdcccb6"

  }

}
 
 
Can somebody help me, please.
Categories:
  • trice602 Profile Picture
    13,760 Super User 2025 Season 1 on 23 Feb 2025 at 20:06:07
    Power Automate doesn't save attachments correctly
    If I can help with anything else please let me know or tag me in a future post, I enjoy reading and answering questions.  Always glad to help!  Tom 💯💯💯💯💯
  • trice602 Profile Picture
    13,760 Super User 2025 Season 1 on 23 Feb 2025 at 20:05:37
    Power Automate doesn't save attachments correctly
    Hey there!
     
    I am following up on this post power automate doesn't save attachments correctly in this category ai builder from 08/23/2024.  I know the post is a little older, but it is a common question here so wanted to take a moment and follow-up. I see there have been 3 replies and 2 likes and asking if your question has been answered.  If so, please help the community out by completing one or more of the following actions!  Thanks in advance!
     
    Easy as 1-2-3 ‼️💯⭐😎🆒🙏
     
    1) Mark a reply as a verified answer - this is essential, and it helps others with the same general question find this thread. ✅
    2) You can also mark one of more replies as a verified answer.  Please take a moment and give the author credit for volunteering their time. ✌️
    3) Like one or more replies.  Kudos always greatly appreciated! 👍
     
    Pro tip:  if you found your own solution or workaround, feel free to add a reply to your own post and mark it as the solution too!  The goal is to get this thread marked with a verified answer by anyone that finds one or more replies helpful!
     
    Again, thanks in advance for reading and responding, always glad to help!  Tom 💯💯💯💯💯
  • Suggested answer
    trice602 Profile Picture
    13,760 Super User 2025 Season 1 on 25 Aug 2024 at 15:26:28
    Power Automate doesn't save attachments correctly
    Hi,
     
    The most likely root cause are the settings in the trigger.  Make sure these are both set to Yes.  I will also share one of the most important things about this flow:  RESUBMITTING test runs will not correctly save your attachment content!!!  I have learned from experience that in order to retest your flows with attachments, you need to send a new email.  That means that maybe your flow is already setup correctly but you are resubmitting previous test runs and finding those attachments are not readable.  
     
     
    Then in the create file action, make sure you point to the contentBytes in your trigger.
     
     
     
    ------------------------------------------------


    If this was helpful, please like and/or mark as a verified answer to help others find this too!


    Always glad to help! 💯💯💯💯💯

    Tom 

    Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn

     

     
  • Suggested answer
    StewC Profile Picture
    93 on 24 Aug 2024 at 19:30:18
    Power Automate doesn't save attachments correctly
    I have a flow almost exactly like this. After the On new email action, I test a condition, branch, then on either branch I create a One Drive file.
     
    The one difference is that, inside both of the For Each Attachment loops, I added the Outlook action Get Attachment (v2) immediately before the OneDrive Create file action. Then pull the dynamic values for Name and ContentBytes from the Get Attachment action -- NOT the On Mail trigger action.
     
    Before I added that action, I had the same results as you. Adding this extra action, the attachment saves correctly. I've found this in a few places in Power Automate: the trigger action alone seems like it should provide all the info...but it just doesn't.
     
    Let me know if this works for you.
     
    Stew
     
  • Suggested answer
    Michael E. Gernaey Profile Picture
    41,254 Super User 2025 Season 1 on 23 Aug 2024 at 22:12:34
    Power Automate doesn't save attachments correctly
    Hi
     
    Have you looked at the contents of the Files? is it string / 8 / 64 base anything?
     
    I am wondering if you are actually writing the improper contents

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard