I was recently working on a project where the client wanted to use the REST API to create SharePoint files, get their properties, and delete them using Power Automate.
We need the correct REST API URI to do all these things, starting with GetFolderByServerRelativeUrl.
In this tutorial, I will show you how to use this powerful endpoint to manage files in SharePoint:
- Create a file in a SharePoint document library
- Get file details
- Delete a file from a SharePoint document library, etc.
Create a File in SharePoint Using REST API in Power Automate
I will show you how to create a File in the SharePoint document library using the REST API in Power Automate. Here, I will create a .txt file.
- Open Power Automate and create an Instant cloud flow that will trigger the flow manually.
- Add a Send an HTTP request to SharePoint action under the trigger and provide the below parameters:
- Site Address: Select the SharePoint site address from the dynamic content.
- Method: Select POST as the method.
- Uri: Provide the below URI:
_api/web/GetFolderByServerRelativeUrl('/sites/YourSiteName/YourLibraryName')/Files/add(url='sample.txt',overwrite=true)
Replace:
- /sites/YourSiteName/YourLibraryName with the correct path to your library or folder.
- ‘sample.txt‘ with the name of the file you want to create.
- Click the Show All button to display all advanced parameters.
- Headers: Click on the Switch to text mode button to access the icon and input the JSON. Copy and paste the code below in the Headers section.
{
"Accept": "application/json;odata=verbose",
"Content-Type": "text/plain"
}
You can also use “application/json” or “application/octet-stream” depending on your content.
- Body:
Hello, this is a file created using REST API in Power Automate!

- Then, save the flow and run it manually.
- Once the flow runs, you’ll see the file created in your SharePoint document library with the content you provided.

If you want to create a different type of file, then use the endpoint below:
_api/web/GetFolderByServerRelativeUrl('/sites/YourSiteName/YourLibraryName')/Files/add(url='FileName.extension',overwrite=true)
Now let’s see some of the examples:
Create a Word Document in SharePoint Document Library Using REST API
I am using the same document library to store the Word document file. Let’s see how to create it using Power Automate.
- Create an Instant cloud flow with a trigger (Manually trigger a flow).
- Add a Send an HTTP request to SharePoint action under the trigger and provide the below parameters:
- Site Address: Select the SharePoint site address from the dynamic content.
- Method: Select Post as the method.
- Uri: Provide the below URI:
_api/web/GetFolderByServerRelativeUrl('/sites/YourSiteName/YourLibraryName')/Files/add(url='report.docx',overwrite=true)
- Click on the Show all button to display all the Advanced parameters.
- Headers: Click on the Switch to text mode button to the icon to input the json. Copy and paste the code below in the Headers section.
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
}
- Body:
Hello, this is a file created using REST API in Power Automate!
Some plain text content will be written, but it won’t be fully formatted like a true Word document.

- Save the flow and run it once it runs successfully. Then, go to the SharePoint document library, and you can see that the Word document was created.

You can create a Word document file using SharePoint REST API in Power Automate.
Get File Details in SharePoint Library Using REST API in Power Automate
With the Send an HTTP request to SharePoint action and the REST API endpoint, you can get everything from a file’s name and URL to its size, author, and even version info in Power Automate.
To do this, follow the steps below:
- Create an Instant cloud flow with a trigger (Manually trigger a flow).
- Add a Send an HTTP request to SharePoint action under the trigger and provide the below parameters:
- Site Address: Select the SharePoint site address from the dynamic content.
- Method: Select Get as the method.
- Uri: Provide the below URI:
_api/web/GetFolderByServerRelativeUrl('/sites/YourSiteName/YourLibraryName')/Files('SampleFile.pdf')
Replace:
- /sites/YourSiteName/YourLibraryName: with the correct path to your library or folder.
- SampleFile.pdf: with the name of the file you want to get.
- Click the Show All button to display all advanced parameters.
- Headers: Click on the Switch to text mode button to the icon to input the json. Copy and paste the code below in the Headers section.
{
"Accept": "application/json;odata=verbose"
}

- Now save the flow and run it manually. Once the flow runs successfully, click the Run Flow button. Then, click Send an HTTP request to SharePoint action and check the output section.

Note:
When you use the REST API in Power Automate with the endpoint _api/web/GetFileByServerRelativeUrl(‘/sites/YourSiteName/Shared Documents/YourFile.pdf’), it returns only the file properties and metadata, not the actual file content. This includes details like the file name, server relative URL, unique ID, who created or last modified the file, and values of any custom columns you’ve added in the SharePoint library (like Status, Category, or Project).
Get File From SharePoint Document Library Using REST API in Power Automate
In the above example, we saw how to get the properties and metadata of a file using Rest API in Power Automate. In this example, I will demonstrate how to verify the existence of a file in a SharePoint document library using the SharePoint REST API in Power Automate.
Check the screenshot below, which tells that the sample text file is present in the Report Storage:

Now, I want to check if a file named sample.txt is present in the Report Storage document library. If the file exists, Power Automate will send an email to the specified recipient with the file attached.
Follow the steps below:
- Create an instant cloud flow with a trigger: Manually trigger a flow.
- Add a Send an HTTP request to SharePoint action:
- Site Address: Select the SharePoint site address from the dynamic content when the library is present.
- Method: Select Get as the method.
- Uri: Provide the below URI:
_api/web/GetFileByServerRelativeUrl('/sites/YourSiteName/YourLibraryName/FileName.extension')/$value
Ensure that you replace the site name, library name, and file name (including the extension) with your specific requirements.
- Click on the Show all button to display all the Advanced parameters.
- Headers: Provide the following headers:
{
"Accept": "application/octet-stream"
}

- Then, add a Send an email (V2) action to notify the user that the file is present, and provide the required parameters as shown below:
- To: Provide the user’s email address.
- Subject: Give a subject to the email.
- Body: Specify the body using dynamic content.
Hi,
Please find attached the invoice you requested.
File Name: sample.txt
Date Sent: [utcNow()]
Best regards,
TSinfo Technologies Pvt. Ltd.
- Click on the Show all button to display all the Advanced parameters.
- Attachments:
- Name – 1: sample.txt
- Content – 1: Provide the above HTTP action body using dynamic content:
- Attachments:
body('Send_an_HTTP_request_to_SharePoint')

- Now, save the flow and run it manually. Once the flow runs successfully, go to the Outlook account you specified, and you will receive the following email:

The best part is that you can send any file (PDF, Excel, etc.) using this Power Automate method.
Get All Files From SharePoint Document Library Using REST API in Power Automate
Usually, when we need to get all files from a document library in Power Automate, we use the Get files (properties only) action. However, you can also retrieve files using the SharePoint REST API in Power Automate. Let’s see how to do this.
To verify, I have a SharePoint Document library called Certification Documents, which contains 21 files. Check the screenshot below:

Now, I want to get all the files using the SharePoint Rest Api and count them.
- Sign in to Power Automate with valid credentials. Then click on + Create and select Instant cloud flow.
- Enter the Flow name and choose the trigger flow (i.e., Manually trigger a flow), then click Create.
- Add a Send an HTTP request to SharePoint action, then provide the side address and below required parameters:
- Method: Select Get as the method.
- Uri: Provide the below URI:
_api/web/GetFolderByServerRelativeUrl('/sites/PowerAutomateTutorial/CertificationDocuments')/Files
- Click on the Show all button to display all the Advanced parameters.
- Headers: copy and paste the below headers:
{
"Accept": "application/json;odata=verbose"
}

- Now add the Apply to each control and provide the below expression:
body('Send_an_HTTP_request_to_SharePoint')?['d']?['results']

- Inside the apply to each control action adds a Compose action and gives the following expression, which returns the file names:
item()?['Name']

- Now save the flow and run it manually. After the flow runs successfully, check how many times it applies to each running; in my case, it is 21 because I have 21 files in the SharePoint document library.

You can get all files from a SharePoint document library using Power Automate with the REST API.
Delete a File in SharePoint Document Library Using REST API
In this example, I will tell you how to delete the file from the SharePoint document library using the REST API in Power Automate.
Here, I will show you two ways to delete the file from the SharePoint Document library in Power Automate with the Rest Api:
- Delete a file using the Delete method of the REST API
- Delete a file using the Post method using the REST API
Delete a File using the Delete Method in the REST API
For this example, I am using the SharePoint Library below and want to delete the Jane Doe PDF file. Check the screenshot below:

Follow the below steps to delete the file using the REST API DELETE method:
- Go to Power Automate and click Create -> Instant Cloud Flow. Select Manually trigger a flow as the trigger.
- Add a Send an HTTP request to SharePoint action to delete files and provide the following parameters:
- Site Address: Select the SharePoint site address from the dynamic content.
- Method: Select DELETE as the method.
- Uri: Provide the below URI:
_api/web/getFileByServerRelativeUrl('/sites/PowerAutomateTutorial/PDFDocument/Jane Doe.pdf')
Here:
- PowerAutomateTutorial: Site Internal Name
- PDFDocument: SharePoint Library Internal Name
- Jane Doe.pdf: File Name with extension

- Now save the flow and run it manually. After the flow successfully runs, go to the SharePoint library. You can see the file has been deleted.

Delete File Using Post Method in REST API
In this example, I use the same document library, but I will delete the Project Deadlines Excel file here. Let’s check out:
- Create an Instant cloud flow with a trigger (Manually trigger a flow).
- Add a Send an HTTP request to SharePoint action, then provide the side address and below required parameters:
- Method: Select Post as the method.
- Uri: Provide the below URI:
_api/contextinfo
- Click on the Show all button to display all the Advanced parameters.
- Headers: copy and paste the below headers:
{
"Accept": "application/json;odata=verbose"
}

- Add a Send an HTTP request to SharePoint action, then provide the side address and below required parameters:
- Method: Select Post as the method.
- Uri: Provide the below URI:
_api/web/getfilebyserverrelativeurl('/sites/PowerAutomateTutorial/ReportStorage/Project Deadlines.xlsx')
- Click on the Show all button to display all the Advanced parameters.
- Headers: copy and paste the below headers:
{
"Accept": "application/json;odata=verbose",
"X-RequestDigest": "body('Send_an_HTTP_request_to_SharePoint')?['d']['GetContextWebInformation']['FormDigestValue']
",
"IF-MATCH": "*",
"X-HTTP-Method": "DELETE"
}

- Save the flow and run it manually. Once the flow runs successfully.
- Go to the SharePoint library. You can see the file has been deleted.

I hope you found this tutorial helpful.
You may also like:
- Convert String to Date for SharePoint list using Power Automate
- Export SharePoint List items to Excel Using Power Automate
- Add a Multistep Form in Power Pages
- Convert True to Yes in Power Automate
- Send a Customized email when a new item is created in a SharePoint list using Power Automate

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.