Power Automate: SharePoint Get file content using path action

Last week we explored SharePoint’s “Get File content” action and explained that we could get the file’s contents, like an Excel file. It’s quite a convenient way to get files, but it requires us to know the file and can point it out in the UI or provide the file’s ID. This is not convenient when we want to dynamically fetch the information, where we know the file’s path but don’t know its ID. To do that, we have the “Get file content using path” action we will explore today.

A few notes before we continue. There are analogous functions for OneDrive For Business , like the “Get File Content” action and the “Get File Content using Path” action, in case you’re interested in using OneDrive instead of SharePoint.

Where to find the “Get File Content using path” action?

You can find it in “Standard”.

If you don’t see “SharePoint,” click to expand.

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

Pick “SharePoint”.

Pick the “Get file content using path” action.

where to find the "Get file content using path" action in Power Automate

Here’s what it looks like.

Here's what the "Get file content using path" action looks like

There are also advanced options that you can pick by pressing the “Show advanced options”.

Here's what the "Get file content using path" action looks like with expanded advanced options

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

Usage

The usage is quite simple. There are two parameters:

  1. The SharePoint site where you have the file
  2. The file itself.

You must note that you can pick the file from the UI or provide its path. Here’s what it looks like:

Example usage of "Get file content using path" action in Power Automate

When we run it, we get the following:

Notice that the data that we get looks “strange”. Since we’re getting an Excel file with an internal structure that is not readable by us, we’re getting its result in base64. If you don’t know what it is, don’t worry. In this case, consider it as “data” and provide it to the actions that require the information, and Power Automate will take care of the rest.

What about if we try to fetch the information from a text file like this?

The “Get file content using path” action will return the following.

Since we’re getting a text file, we won’t get it as a base64 file, but we’ll get its contents. This works the same way with CSV files, where the information is stored in clear text that you can “read”. Again, this is a great way to get information in bulk from a file and parse it in subsequential actions.

Finally, look at the advanced properties, like the “Infer Content Type”. This tells Power Automate to look at the extension and try to understand the content type. For an Excel file, it’s something like this:

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Applications need this information to know what to do with the files and how to open them, for example.

It’s super rare that you’ll need to worry about this, but I wanted to include an explanation of what it is in case you’re curious or facing a situation where you need it. If you do, please let me know in the comments so I can include it here for others to benefit.

Non-intuitive behaviors

The “Get File content using path” action looks identical to the “Get file content” action. Here’s an example, but notice the subtle difference about the “File Identifier”. 

We won’t use it in the “Get file content using path” action, so if you provide it, it will fail with the following error:

File not found
clientRequestId: 50b44c69-778f-457d-b124-172b9d49a3e8
serviceRequestId: 50b44c69-778f-457d-b124-172b9d49a3e8

This is the same error message if the file doesn’t exist since it will try to find the path of the string you provide, regardless of what it is. So if you get this error, please look at the value inserted in the path and compare it with your SharePoint site’s file to see if it is there.

Limitations

I could not find a hard limitation for the size of the files, but I’m sure there’s one. Don’t try to parse large files because you can hit Power Automate’s throughput limitations.

If you have found a limitation we should be aware of, please comment, and I’ll include it in the article for everyone to benefit.

Recommendations

Here are some things to keep in mind.

Name it correctly

The name is super important in this case because we can pick the file from the UI and get the file’s path from other actions in the Flow. The path can even be generated dynamically based on additional information, so it’s important to indicate how it’s calculated. Therefore, always build the name so others can understand your use without opening the action and checking the details.

Always add a comment.

Adding a comment will also help avoid mistakes. Indicate where the path comes from, for example, how you get it. 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 that you can use to help you make your Flow resistant to issues. You can check all details here.

Back to the Power Automate Action Reference.

Photo by Clem Onojeghuo on Unsplash

 

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

Leave a Reply

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