October 16, 2024

Today we’ll cover the same action on two different platforms. Almost two different platforms. OneDrive and OneDrive for Business. There’s a lot to cover between both, but one action is common for both and works the same way. The “Get File Content.”

It does exactly as advertised. You define a file, and the action fetches the file’s content and returns it to you.

Where to find it?

I’ll show you where to find it in both OneDrive and OneDrive for Business, but after this, I’ll use OneDrive for Business since both work the same way.

OneDrive

To get it for your OneDrive:

You need to expand and search for “OneDrive.” Or you can search for it in the search bar, but be careful not to select “OneDrive for Business.”

Select “Get file content,” and this is what it looks like:

OneDrive for Business

To get it for your OneDrive for Business, it’s displayed in the preview, but if you can’t find it for some reason, expand and search for it.

Select “Get file content”:

Looks the same as before.

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

Usage

You can use it in 2 ways:

  1. Select the file by selecting the folder icon and going through your folders until you find the file you want.
  1. Build the path dynamically and add it to the “File” field:

As you can see above, the “unique identifier” of the file translates to the file path in your OneDrive tree (almost).

Let’s look at the first case:

Looks good. Let’s copy and paste the path and see what we get:

I chose this example for a reason.

This happens all the time where people select the file from a folder and the Flow works fine but when they copy the file to a variable for example it fails. The reason is in the field’s description. It’s requesting the “File Identifier” and not the “File Path.” Although we see the path when we select the file, Power Automate will convert it behind the scenes for us.

Please be careful. If you want to get the file by path, there’s another action for that called (you guessed it), “Get file content using the path.”

Limitations

You need to use the identifier and not the file path. To get it, you can use another handy action called “Get file metadata using path” that will fetch the file details, including its unique identifier, in case you want to fetch the data.

In all fairness, I should not include it here as a limitation. It’s clear in the action that you should use the file identifier. I’m stressing it again because I see this mistake a lot!

Recommendations

Here are some things to keep in mind.

Name it correctly

The name is super important in this case since we’re getting the file by the unique identifier. Always build the name so that other people can understand that you’re using the unique identifier and not the path. As you saw before, using the path will result in an error, and if the name is not clear, it will take some time to understand the issue.

Always add a comment.

Adding a comment will also help to avoid mistakes. Indicate that we’re providing the unique identifier and, if possible, the source where you’re getting it. This will enable faster debugging in case something goes wrong.

If you have a path

Don’t try to build a unique identifier yourself. Always fetch it from another connector because:

  1. You will always fail in getting the formula 100% correct.
  2. It’s a lot of work for nothing when another action will provide you the value always 100% correct.
  3. If a change in the underlying structure and the unique identifiers change, the Flow will continue to work properly.
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 Brett Jordan 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 →

5 thoughts on “Power Automate: OneDrive for Business – Get File Content Action

  1. I could not find this forever… no matter how many times I searched and searched… THANK YOU SO MUCHHH!!

    1. Hi Harrison,
      I’m so happy!!!! Glad it helped.
      Anything else, please let me know.
      Glad to help
      Manuel

  2. This is brilliant, thank you for pointing out the difference in using GetFileContent and GetFileContentUsingPath. It was driving me and several others crazy!

Leave a Reply

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

Mastodon