Many people don’t know this, but you can add attachments to a SharePoint list row. It’s convenient and much better than having a folder with files. And with SharePoint’s “Add attachment” action, we can automate the whole process.

A previous note before we continue in case you don’t know how to display the attachments in your list. To do it, in any list, go to “Add column”:

You may need to scroll down to find “attachments”:

After selecting it, don’t forget to press “apply”.

A new column will show up in your list with the attachments.

Now that we know where to find it in SharePoint let’s see how to automate the process.

Where to find it?

You can find the “add attachment” action in the SharePoint section. Select “Standard”:

You may need to expand to find SharePoint.

Select SharePoint.

Find and select the “add attachment” action:

Here’s what it looks like:

Pro Tip: Power Automate tends to save the most common actions in the main screen, so check there before going trough the full hierarchy. Also you can use the search to quickly find it.

Now that we know how to find it let’s understand how to use it.

Usage

The action does one thing, but it does it well. Get a file and add it to the SharePoint site’s list row.

Let’s create a sample list to test our process.

And a Flow that can insert the data. We’ll do the following:

  1. Create a new item in the list.
  2. Get the file contents using OneDrive’s “Get File content” action.
  3. Add the file to the newly created item.

Here’s what it looks like:

Let’s run it and see what we get. Here’s the SharePoint list result:

We have an attachment, and if we press the row, we’ll get the results:

Please note that you don’t need to keep the same file name in action. You can define any other name, and it will be created with that name on SharePoint. Here’s an example:

And we get:

Limitations

You should limit concurrency while using the “add attachment” action. For example, if you’re adding multiple files at the same time, do it sequentially; otherwise, you’ll have Flows that don’t stop, like this:

But if you do it consecutively, you’ll be able to run it instantly.

Another limitation is that the names need to be unique.

If you try to insert a value with the same name, you’ll get:

The specified name is already in use.

The document or folder name was not changed.  To change the name to a different value, close this dialog and edit the properties of the document or folder.
clientRequestId: c62f3b1f-07ea-467b-bb9a-406d73234120
serviceRequestId: 26681fa0-20e5-3000-d4f1-1971357fae71

This will happen even if the files are completely different. As long as the name is other, then you’ll get this exception.

A hidden issue

Sometimes you may get the following error “page” instead of an error message.

<!DOCTYPE html>
<html>
    <head>
        <title>The resource cannot be found.</title>
        <meta name="viewport" content="width=device-width" />
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; }
         @media screen and (max-width: 639px) {
          pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
         }
         @media screen and (max-width: 479px) {
          pre { width: 280px; }
         }
        </style>
    </head>

    <body bgcolor="white">

            <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>

            <h2> <i>The resource cannot be found.</i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. &nbsp;Please review the following URL and make sure that it is spelled correctly.
            <br><br>

            <b> Requested URL: </b>/sites/<redacted>/_api/web/lists/GetByTitle(&#39;Recepci&#243;<redacted> / <redacted>&#39;)/Items(7)/AttachmentFiles/AddUsingPath(decodedUrl=@f)<br><br>

            </font>

    </body>
</html>

clientRequestId: f7a73f84-3a71-4e60-8cda-ef1258a8bcc2

Here’s what it looks like in Power Automate.

And this is a “normal” exception:

So what’s happening here? We’re getting the values from the trigger.

The issue is not the trigger but the name of the list. The problem is not the trigger but what happens when you call the “add attachment”. When the list name is provided dynamically, the connector makes an HTTP request like this:

SharePoint needs to do this call to find the list’s ID so that it can perform the action, but the _api/web/lists/getbytitle has an issue that limits the forward slash. So the action “panics” and returns an exception instead of an error. But, of course, this won’t happen if you pick the list from the dropdown since SharePoint doesn’t need to try to find the list.

I tried encoding the whole string, only the forward-slash, and it didn’t work. The only solution I found was to pick it from the dropdown, and it all started working. So if you have lists with forward-slash, you know that you always need to hard-code the list in the “add attachment” action.

I believe this is a bug, but it’s tricky to understand, but I wanted for you to understand it in case you’re spending time (in my case, a few hours) trying to figure it out.

Recommendations

Here are some things to keep in mind.

Avoid using dynamic values, especially the list name

Although you can provide the dynamic value for the SharePoint site and list name, please avoid doing it. There are some limitations in the API that Power Automate uses to access SharePoint so that you may have strange issues (like described above).

Name it correctly

The name is super important since “add attachment” doesn’t tell much. Always build the word so that other people can understand what you are using without opening the action and checking the details.

Always add a comment.

Adding a comment will also help avoid mistakes. Indicate the file we’re adding, for example, to what site and list and the point. But, again, it’s essential to enable faster debugging when something goes wrong.

Always deal with errors.

Have your Flow fail graciously and notify someone that something failed. It’s horrible to have failing Flows in Power Automate since they may go unlooked-for a while or generate even worse errors. I have a template, and a template that you can use that will help you make your Flow resistant to issues. You can check all details here.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Action Reference.

Photo by Jen Theodore on Unsplash

Manuel Gomes

I'm a previous Project Manager, and Developer now focused on delivering quality articles and projects here on the site. I've worked in the past for companies like Bayer, Sybase (now SAP), and Pestana Hotel Group and using that knowledge to help you automate your daily tasks

View all posts by Manuel Gomes →

Leave a Reply

Your email address will not be published. Required fields are marked *