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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Get sharepoint item attachment and save to folder

(0) ShareShare
ReportReport
Posted on by 42

Hi

 

I am building a powerapp with sharepoint behind it. 

 

The user enters sharepoint list information on a form in the powerapp and may add attachments. 

 

We want those attachments to also be saved separately to a directory folder.

 

I can't seem to find a reference to the attachments in any of the connectors. 

 

Is this possible? 

I have the same question (0)
  • Verified answer
    Ellis Karim Profile Picture
    11,463 Super User 2025 Season 2 on at
    Re: Get sharepoint item attachment and save to folder

    SharePoint List item attachments are stored in the Attachments folder:

    .../Lists/<ListName>/Attachments/[ID]/filename.xxx

    where [ID] is the SharePoint item ID

    Example:

    ekarim2020_0-1631205606525.png

    Site: name: ContractsRepo

    List name: Contracts Library

    List Item ID: 52

    Attachment name: Diskeeper Dashboard Summary Report.pdf

    https://tenancyname.sharepoint.com/sites/ContractsRepo/Lists/Contracts%20Library/Attachments/52/Diskeeper Dashboard Summary Report.pdf

    To get all attachments for a SharePoint List item, your flow will resemble something similar to below. The attachment(s) is stored in an array and sent in an Approval:

    ListitemAttachments.jpg

     

     

     

    {
     "name": @{outputs('Get_file_metadata')?['body/DisplayName']},
     "content": {
     "$content-type": @{body('Get_attachment_content')['body']['$content-type']},
     "$content": @{body('Get_attachment_content')['body']['$content']}
     }
    }

     

     

     

    ekarim2020_2-1631208402984.png

    ekarim2020_0-1631208215560.png

    To save the attachments to a SharePoint document library, the varAttachment arrary needs the following format:

    ekarim2020_3-1631208605852.png

    Use a loop to save each attachment to a document library:

    ekarim2020_5-1631208979364.png

    Hope this helps.

    Ellis

  • BenChainCode Profile Picture
    42 on at
    Re: Get sharepoint item attachment and save to folder

    Thanks for the fast response. 

     

    What is the last File Content field? ContentBytes.$...something. I don't have it as selectable dynamic content

  • Ellis Karim Profile Picture
    11,463 Super User 2025 Season 2 on at
    Re: Get sharepoint item attachment and save to folder

    The last ContentBytes expression is:

    items('Apply_to_each_2')['ContentBytes']['$content']

    I had taken the screen shots from two different working flows.

    ekarim2020_1-1631283372043.png

    ekarim2020_4-1631283736686.png

     

    Ellis

     

     

  • BenChainCode Profile Picture
    42 on at
    Re: Get sharepoint item attachment and save to folder

    Before you responded I tried it simply using the Attachment Content option that was available and it does seem to work. The flow itself results in an FAIL but the attachments are saved so I'm not sure why it is failing. 

     

    Thanks for your assistance 🙂

  • Ellis Karim Profile Picture
    11,463 Super User 2025 Season 2 on at
    Re: Get sharepoint item attachment and save to folder

    Can you share your update flow, along with any expressions.

    Ellis

  • BenChainCode Profile Picture
    42 on at
    Re: Get sharepoint item attachment and save to folder

    Updating to your provided expression works without issue 🙂 

  • BenChainCode Profile Picture
    42 on at
    Re: Get sharepoint item attachment and save to folder

    @ekarim2020 Hmm so upon closer inspection, while the files were saving to folders. On opening the file, it seems they were corrupted.

     

    All the files are saved as 52 bytes. Seems only the file name is actually being saved and not the content of the file. I assume I missed a step but I can't spot it. 

     

    My flow: 

    1. Trigger: When a list item is created
    2. Create New folder
    3. Get attachments from list item id
    4. Initialise variable: Array, varAttachments
    5. Apply to each (get attachments body):
      1. Get attachment content: id=trigger id, file identifier= apply to each id
        Get file metadata = apply to each id
      2. Append to array variable
        1. {
          "name": @{outputs('Get_file_metadata')?['body/DisplayName']},
          "ContentBytes": @{body('Get_attachment_content')?['body']}
          }
      3. Apply to each (varattachment)
        1. Create file: file content = items('Apply_to_each_3')['ContentBytes']['$content']
  • Community Power Platform Member Profile Picture
    on at
    Re: Get sharepoint item attachment and save to folder

    Hi I am receiving this error, my files got saved but not in the folder, it was saved outside. And in while running the flow i am receiving this error

     

    NAM2411_0-1659598539452.pngNAM2411_1-1659598557411.png

    NAM2411_2-1659598645381.png

    Thanks in advance, and please try to revert ASAP as it's a bit urgent.

  • BenChainCode Profile Picture
    42 on at
    Re: Get sharepoint item attachment and save to folder

    I cannot help but I suggest you make a new topic.

     

    Also you should show the actual error: open up the for each look and find the specific file or error

  • Community Power Platform Member Profile Picture
    on at
    Re: Get sharepoint item attachment and save to folder

    I am getting the error in the last flow i.e. apply to each (2). Can you please explain the last step that is create file where there is the concept of content bytes. I have done it this way, but i guess this might be wrong

     

    Thanks 

     

    Untitled.png

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 797 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 425 Moderator

#3
developerAJ Profile Picture

developerAJ 319

Last 30 days Overall leaderboard