How to Get SharePoint File Content in Power Automate: File Paths vs URLs

Power Automate: How to Get SharePoint File Content in Power Automate: File Paths vs URLs
First Published: May 5, 2025

File paths or URLs? Get it wrong, and your flow fails. Here’s how to get it right.

When building flows in Power Automate that work with SharePoint, it’s essential to use the correct path format. Actions like “Get file content using path”“Get file metadata using path”, and “Get folder metadata using path” all depend on this.

SharePoint supports multiple types of URLs, including full web linksfile paths, and server-relative URLs. But it’s not always clear which one to use. Using the wrong type can cause flow errors or unexpected failures.

A common mistake is to use sharing links (the kind you get from the “Share” button in SharePoint). These may look valid but don’t point to the actual file location, so they won’t work in Power Automate.

In this post, I’ll explain the differences between these URL types, when to use each one, and share working examples to help you select the right format so your flows don’t fail unexpectedly.

CONTENTS

  1. SharePoint File Paths Overview
  2. Examples using the Get File Content action
  3. Sample Runtime Outputs
  4. How to Create Files using the File Content
  5. Troubleshooting “File Not Found” Errors
  6. Summary
  7. Notes

1. SharePoint File Paths Overview

Privacy Settings

SharePoint URLs generally come in three forms.  Absolute URL, Server-Relative URL and a File Path
SharePoint path options: Absolute URL, Server-Relative URL, and File Path (library-relative). In this post, you’ll learn how each one works in Power Automate.

SharePoint supports several URL formats, but this post focuses on the three most relevant types for working with documents or folders in Power Automate.

1. What is an Absolute URL?

An Absolute URL is a full web address (including https://domain, and path directly to a file). In SharePoint, it’s often referred to as a direct link, especially when copying a link to a file or folder via the SharePoint interface.

Example:

https://tenant.sharepoint.com/sites/SiteName/Shared Documents/Folder/File.pdf

https://tenant.sharepoint.com/sites/Contracts/Lists/ContractsLibrary/AllItems.aspx

  •  Surprisingly, the Get file content using path and Get file metadata using path actions do accept an absolute URL as input, even though it’s not in the official documentation.
  •  OneDrive for Business actions (such as Get file content using path and Get file metadata using path) do not support absolute URLs.

2. What is a File Path?

A File Path refers to the location of a file within a site’s structure, starting from the document library and including any subfolders leading to the file.

Example: /Shared Documents/Folder/File.pdf
 Shared Documents/Folder/File.pdf

  • Power Automate accepts the file path with or without the leading slash /. Both formats work.
  • If you use the file picker to select a file, Power Automate automatically inserts the leading slash / (it prefers this format). More on this in the Examples section below.
  • Used in actions like “Get file content using path”“Get file metadata using path”, and “Get folder metadata using path”.

Website-Relative URL is also another term you may find in SharePoint documentation. File Path = Website-Relative URL.

3. What is a Server-Relative URL?

Server-Relative URL is a path that starts at the root of the SharePoint tenant and includes the site and document library. It is sometimes called a domain-relative URL.

Example: Using the following Absolute URL
https://tenant.sharepoint.com/sites/SiteName/Shared Documents/Folder/File.pdf

The Server-Relative URL would be: /sites/SiteName/Shared Documents/Folder/File.pdf
 sites/SiteName/Shared Documents/Folder/File.pdf

  • Server-Relative URLs must always begin with a forward slash /.
  • Mainly used in REST APIs like “Send an HTTP request to SharePoint“, its use depends on the endpoint you are calling.

2. Examples using the Get File Content action

Everything I explain here for the “Get file content using path” also applies to “Get file metadata using path” and “Get folder metadata using path” actions in Power Automate. All of these actions require the actual file or folder path, not a sharing link Important: The “Get folder metadata using path” action requires a path to a folder, not a file. Supplying a file path will result in an error.

1. Absolute URL example

The first example uses the “Get file content using path” action with an absolute URL:

Power Automate “Get file content using path” action using an absolute URL as input. The File Path field is set to a variable named absoluteURL.
Example of using ‘Get file content using path’ action in Power Automate with an absolute URL.

The absolute URL example:

https://badpassword.sharepoint.com/sites/CustomerIssueManagement/Shared Documents/Apps/Microsoft Forms/Customer Service Demo Form/Application Form/Certification-Poster-en-us_Ellis Karim.pdf

Actions like “Get file content using path”“Get file metadata using path”, and “Get folder metadata using path” can use an absolute URL even though they are not documented as doing so TIP: How to get the absolute URL of a File

You can easily get the absolute URL of a file by copying its direct link in SharePoint as shown below:

You can easily get the absolute URL of the file by copying the direct link as
Demonstrating how to copy the direct link of a file in SharePoint, from the details of the selected document.

The absolute URL I copied was:

https://badpassword.sharepoint.com/sites/DemoSite/Shared%20Documents/Report_2025-04-22T16_54_05.6312659Z.xlsx

And here is an animated GIF showing how to copy the direct link to a file in SharePoint to get its absolute URL:

And here is an animated GIF showing how to copy the direct link to a file in SharePoint to get its absolute URL
Animated GIF demonstrating how to copy the direct link of a file in SharePoint, from the details of the selected document.

2. File Path example

This example uses the same “Get file content using path” action with a file path:

Power Automate “Get file content using path” action using a standard SharePoint file path. The File Path field is set to a variable named filePath, representing a site-relative path starting from the document library.
Example of using ‘Get file content using path’ action in Power Automate with a File Path.

File Path example:

/Shared Documents/Apps/Microsoft Forms/Customer Service Demo Form/Application Form/Certification-Poster-en-us_Ellis Karim.pdf

File Picker example: I selected the file via the UI, and Power Automate added the leading slash /:

Power Automate: Get file content using path action where I select a file. The path is a File Path
Animation showing a user selecting a file in the Get File Content using Path action.

Power Automate defaulted to using a leading slash / when using the file picker:

 /Shared Documents/Apps/Microsoft Forms/Customer Service Demo Form/Application Form/Certification-Poster-en-us_Ellis Karim.pdf

The file path without the leading slash / would also work when entered manually or used in a variable:

 Shared Documents/Apps/Microsoft Forms/Customer Service Demo Form/Application Form/Certification-Poster-en-us_Ellis Karim.pdf

 TIP: How to get the File Path from a URL

We can use the following expression to extract the File Path from a URL:

initialise a variable with a URL
Initializing a variable in Power Automate to store a SharePoint URL.
1234slice(    variables('link'),    nthIndexOf(variables('link'),'/', 5)    )

The expression finds the 5th forward slash / in the link, then slices the link string from that point onwards, meaning it removes everything before the 5th slash and keeps the rest.

The expression finds the 5th forward slash / in the link, then slices the link string from that point onwards, meaning it removes everything before the 5th slash and keeps the rest.
How the URL will be sliced in order to get the the File Path from the URL.
extract File Path from URL using the expression
slice(
    variables('link'),
    nthIndexOf(variables('link'),'/', 5)
    )
Power Automate expression for extracting the file path from a URL.

Runtime output showing the File Path that was extracted from the URL.

extracted File path
The runtime output showing the expression showing the File Path that was extracted from the URL.

3. Server Relative URL example

In this example I called the REST API (using the “Send an HTTP request to SharePoint” action) with GetFileByServerRelativeUrl and provided the server-relative URL. This returned the file content using $value:

Power Automate “Send an HTTP request to SharePoint” action using a server-relative URL. The Uri field calls _api/web/GetFileByServerRelativeUrl with a dynamic variable ServerRelativeUrl.
Example of sending an HTTP request to SharePoint using the server-relative URL format in Power Automate.

The Server Relative URL example:

_api/web/GetFileByServerRelativeUrl('/sites/CustomerIssueManagement/Shared Documents/Apps/Microsoft Forms/Customer Service Demo Form/Application Form/Certification-Poster-en-us_Ellis Karim.pdf')/$value

Without the $value segment, we would just get details about the file. With $value, we get the actual file content:

_api/web/GetFileByServerRelativeUrl(...)/$value

Remember: Server-Relative URLs must always begin with a forward slash /.

The next example uses GetFolderByServerRelativeUrl to retrieve folder info, again using a server-relative URL. The server-relative URL points to a folder, not a file:

And this example shows the use of the Server Relative URL in a GetFolderbyServerRelativeUrl function:
Using the GetFolderByServerRelativeUrl action in SharePoint to retrieve folder metadata in Power Automate.

 TIP: How to get the server-relative URL

You can easily extract the server-relative path from a full SharePoint file URL (absolute URL) using the uriPath() function. For example:

uriPath('https://badpassword.sharepoint.com/sites/DemoSite/Shared%20Documents/demo3PDF.pdf')

returns

/sites/DemoSite/Shared%20Documents/demo3PDF.pdf

3. Sample Runtime Outputs

Below I show three working examples that demonstrate how to retrieve file content from SharePoint in Power Automate, using different URL formats. In all three cases, the output confirms that the file was successfully retrieved, as shown by the "$content-type" and base64-encoded content in "$content".

1. Absolute URL Runtime Output

In the first example, the Get file content using path action uses a full absolute URL (https://...) is used in the File Path field. Surprisingly, this works, even though it’s not officially documented as supported.

In the first Get file content using path action, a full absolute URL (https://...) is used in the File Path field.

Surprisingly, this works, even though it's not officially documented as supported
Using ‘Get file content using path’ with the full absolute URL works in SharePoint, even though it’s undocumented.

2. File Path Runtime Output

This example uses a standard file path (also known as a website-relative URL), starting from the document library: Shared Documents/Apps/... This is the officially supported format for actions like Get file content using path and Get file metadata using path.

This example uses a standard file path (also known as a website-relative URL), starting from the document library:
Shared Documents/Apps/...

This is the officially supported format for actions like Get file content using path and Get file metadata using path.
Power Automate ‘Get file content using path’ retrieving a PDF from SharePoint using the file path.

3. Server-Relative URL Runtime Output

This example uses the Send an HTTP request to SharePoint action to call the REST API directly.

Here, the file is retrieved using a server-relative URL via _api/web/GetFileByServerRelativeUrl(...). This format starts with /sites/... and is required when using the REST API. [3]

This example uses the Send an HTTP request to SharePoint action to call the REST API directly.

Here, the file is retrieved using a server-relative URL via _api/web/GetFileByServerRelativeUrl(...).

This format starts with /sites/... and is required when using the REST API.
Using the ‘Send an HTTP request to SharePoint’ with GetFileByServerRelativeUrl to retrieve file content.

How to Create Files using the File Content

The output from the following actions can be used as the File Content input in a Create file action:

  • Get file content using path – using an Absolute URL
  • Get file content using path – using a File path
  • Send an HTTP request to SharePoint

The file contents can be used as input in a Create file action as we see below:

The image below shows a Create file action in Power Automate, with arrows indicating how the File Content input can be populated using the outputs from these actions.
Supplying file content to the OneDrive ‘Create file’ action. Outputs from both ‘Get file content using path’ and an ‘HTTP request to SharePoint‘ can be used.

Troubleshooting File not found Errors

If you’re seeing a 404 File Not Found error in Power Automate when using the Get file content using path action, try the following steps below.

Screenshot of a failed Power Automate flow showing a "Get file content using path" action. The action fails with a 404 File Not Found error. The **File Path** input contains an encoded absolute URL (`https%3A%2F%2Fbadpassword.sharepoint.com%2Fsites...`). The **status** in the output is `404`, and the error message reads: "File not found". A "How to fix" section suggests inspecting inputs to ensure the correct file is being referenced.
Flow failure when using ‘Get file content using path’ with an encoded full URL – returns File not found (404).
Screenshot of a failed Power Automate flow showing a "Get file content using path" action. The action fails with a  File Not Found error.
Run details showing the error: File not found (404) when ‘Get file content using path’ fails.

Step 1: Double-check the file path

Make sure the file exists. If the file doesn’t open, it may have been:

  • Moved
  • Renamed
  • Deleted
  • Or you may not have access 

Step 2: Use the unencoded URL, not the encoded URL

URLs are often encoded (e.g. spaces become %20& becomes %26, etc.). For example, the absolute URL link for a file called Report Survey [A]_Ellis Karim (1).PDF could be encoded as:

https://badpassword.sharepoint.com/sites/DemoSite/Shared%20Documents/Report%20Survey%20%5BA%5D_Ellis%20Karim%20(1).PDF

The File Path to Report Survey [A]_Ellis Karim (1).PDF would be encoded as:

/Shared%20Documents/Report%20Survey%20%5BA%5D_Ellis%20Karim%20(1).PDF

When I used an encoded URL or the encoded File Path in the Get file content using path action, the flow failed unexpectedly:

The URL https://badpassword.sharepoint.com/sites/DemoSite/Shared%20Documents/Report%20Survey%20%5BA%5D_Ellis%20Karim%20(1).PDF causes the Get file content using path to fail.
The Get file content using path’ fails when the file path contains URL-encoded characters (e.g. %20%5B%5D)

Yet, when I used the unencoded version of the same URL or File Path, the Get file content using path succeeded:

using the unencoded URL works in the Get file content using path.
Example of using the ‘Get file content using path’ action in Power Automate with an unencoded file path is used.

Because of this behaviour, I recommend using unencoded URLs and File Paths whenever possible in SharePoint actions like Get file content using pathGet file metadata using path, and Get folder metadata using path.

I recommend using unencoded URLs and File Paths

Although these actions can work with encoded values, they are not consistently reliable and may return ‘File not found’ errors. This often happens when flows receive encoded paths from external systems, data sources, or other Power Automate actions (such as Microsoft Forms). The SharePoint connector does not always decode these paths correctly, resulting in unexpected failures.

The SharePoint connector does not always decode paths correctly

We cannot always know in advance whether an encoded URL or file path will work. Some may succeed, while others may fail unpredictably, making them unreliable for use in our automated workflows. To avoid this issue, I suggest decoding paths using the uriComponentToString() function before passing them into these actions.

This limitation does not to apply to the GetFileByServerRelativeUrl(...) function used in the Send an HTTP request to SharePoint action, which seems to work with both encoded and unencoded URLs.

Use unencoded URLs and File Paths in Get File using Path actions.

To convert an encoded URL or file path into a unencoded format, you can use the uriComponentToString() function.

Use uriComponentToString() to decode encoded URLs or file paths before using them.

Example 1: Decoding an Absolute URL

UriComponentToString('https://badpassword.sharepoint.com/sites/DemoSite/Shared%20Documents/Report%20Survey%20%5BA%5D_Ellis%20Karim%20(1).PDF')

returns the unencoded URL:

https://badpassword.sharepoint.com/sites/DemoSite/Shared Documents/Report Survey [A]_Ellis Karim (1).PDF

Example 2: Decoding an encoded File Path

UriComponentToString('/Shared%20Documents/Report%20Survey%20%5BA%5D_Ellis%20Karim%20(1).PDF')

returns the unencoded File Path:

/Shared Documents/Report Survey [A]_Ellis Karim (1).PDF

Using encoded URLs or file paths can sometimes cause Power Automate actions to fail. It’s not always clear why, but it’s likely due to how the SharePoint connector handles special characters (such as spaces, ampersands, or square brackets) within URLs and file paths. The decodeUriComponent() function can also be used to decode encoded characters. Both decodeUriComponent() and uriComponentToString() are valid, documented options for decoding URI-encoded strings in Power Automate, and they produce the same result in standard use cases.[5][6]

Where possible, decode encoded strings using the uriComponentToString() function and use the unencoded version in your flow — particularly for actions like Get file content using path, Get file metadata using path, and Get folder metadata using path.

Summary

SharePoint URLs generally come in three forms.  1. Absolute URL,  2 File Path and 3. Server-Relative URL
Comparing different SharePoint URL formats: Absolute URL, Server-Relative URL, and File Path.

In this post, I looked at the key SharePoint path formats used in Power Automate, how they work, when to use them, and common problems to avoid, including issues with sharing links and encoded URLs:

1. Absolute URLs – full web addresses (starting with https://...). These can work with actions like Get file content using path, but this behaviour isn’t officially documented.

2. File Paths – these refer to the location of a file starting from the document library and include folders and filenames (e.g. /Shared Documents/Folder/File.pdf). This is the recommended and officially documented format for SharePoint actions like Get file content using path, Get file metadata using path, and Get folder metadata using path.

3. Server-Relative URLs – these paths begin with /sites/... or /teams/... and include the site path. They are mainly used with the Send an HTTP request to SharePoint action and must always begin with a forward slash /. [3]

4. SharePoint’s sharing links – don’t use these! They are not actual file paths and will not work in the file or metadata actions.

5. Use unencoded paths: SharePoint connector actions in Power Automate work most reliably with unencoded file paths. Use the uriComponentToString() function to convert encoded values into a readable, usable format before passing them into the action.

Advertisement

https://edge.aditude.io/safeframe/1-1-1/html/container.html

Privacy Settings

 Always use unencoded URLs or file paths (e.g. spaces, ampersands, and brackets should appear as-is, not as %20%26, etc.). If you are unsure whether a path is encoded, decode it first using the uriComponentToString() function.

Notes

decodeUriComponent() – this function also decodes a encoded URI string, converting it back to its original string representation. A URI-encoded string, such as https%3A%2F%2Fcontoso.com, returns the decoded, human-readable form, https://contoso.com.ge Again!: https://intranetfromthetrenches.substack.com/p/never-fear-m365-storage-again

Refer to Microsoft’s documentation on SharePoint URL and tokens for more details on URL types: https://learn.microsoft.com/en-us/sharepoint/dev/general-development/urls-and-tokens-in-sharepoint

SharePoint Connector Reference: https://learn.microsoft.com/en-us/connectors/sharepointonline/

SharePoint Online uses two managed paths for site URLs: /sites/ and /teams/. While /sites/ is the default for most modern sites, some organisations may use /teams/ for team-specific sites. Ensure you use the correct path that matches your site’s URL structure.

Uniform Resource Identifier (URI) – is a string of characters used to identify a resource on the internet. Example of a URI (which is also a URL)https://example.com/docs/file.txt.

uriComponentToString() – this function decodes an encoded URI string, converting it back to its original string representation. A URI-encoded string, such as https%3A%2F%2Fcontoso.com, returns the decoded, human-readable form, https://contoso.com.

About the Author

Ellis Karim

IT Leader | Power Platform Solution Architect | Power Platform Super User & Community Moderator | PRINCE2 & Scrum | Blogger

Reference:

Karim, E (2025). How to Get SharePoint File Content in Power Automate: File Paths vs URLs – Ellis Karim’s Blog [Accessed: 19th October 2025].

Share this on...