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?
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.
You can use it in 2 ways:
- Select the file by selecting the folder icon and going through your folders until you find the file you want.
- 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.
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!
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:
- You will always fail in getting the formula 100% correct.
- It’s a lot of work for nothing when another action will provide you the value always 100% correct.
- If a change in the underlying structure and the unique identifiers change, the Flow will continue to work properly.
Back to the Power Automate Action Reference.