How do I restore removed files in SharePoint with Power Automate

In this Power Automate tutorial, we will see how to restore removed files in SharePoint with Power Automate or Microsoft Flow. And also we will discuss how to restore all removed Files in Sharepoint with Power Automate or Microsoft Flow.

So, we will create a flow that will restore the removed file from Recycle bin in SharePoint with Power Automate.

Restore Removed Files in SharePoint with Power Automate

Here we will see how to restore removed files in SharePoint with Power Automate.

We will create a flow, that will restore the file automatically from Recycle bin when a particular file gets deleted from the SharePoint library using Power Automate or Microsoft Flow.

To accomplish the above scenario, we need to send 2 HTTP requests to SharePoint, one for retrieving the file from recycle bin that gets deleted from the below SharePoint library using the trigger ‘When a file is deleted‘ action, and another to restore the file from recycle bin to the below SharePoint document library.

How to restore removes files in SharePoint using Flow
How to restore removed files in SharePoint using Flow

Steps to Restore Removed Files in SharePoint with Power Automate

Here we will see the steps to restore the removed file in SharePoint with Power Automate.

Step 1: Create a Flow in Power Automate

To create a Flow, log in to Power Automate, then click on Create and select Automated Cloud Flow.

How do i restore removed files in SharePoint using Power Automate
How do i restore removed files in SharePoint using Power Automate

Now provide the Flow name and select the trigger ‘When a file is deleted‘ action. Then click on create

RESTORE REMOVED FILES IN SHAREPOINT WITH POWER AUTOMATE
RESTORE REMOVED FILES IN SHAREPOINT WITH POWER AUTOMATE

Step 2: When a file is deleted

In this step provide the site address and library name from which you want to delete a file in SharePoint.

How to restore removed files in SharePoint with MS Flow
How to restore removed files in SharePoint with MS Flow

Step 3: Retrieve a file from Recycle bin in SharePoint

Now we will send an HTTP request to get a file from the recycle bin, that we will restore later. So click on the Next step and send an HTTP request to SharePoint action.

Then Provide the site address and Method as Get from the dropdown. Then Uri field provide the below API

_api/site/Recyclebin
How to restore removed files in SharePoint with Microsoft Flow
How to restore removed files in SharePoint with Microsoft Flow

Step 4: Filter the file that gets deleted

In this step, we will filter the item that gets deleted from the list item. So click on the Next step and select Filter array action. Then provide From write the below expression

 body('Get_files_from_Recycle_Bin')['d']['results']

Next, click on the Show Advanced option and write the below expression to check deleted file title is equal to Filename with the extension of a file in recycle bin

@equals(item()['Title'], triggerOutputs()?['body/FileNameWithExtension'])
How to restore removed files in SharePoint with Power Automate
How to restore removed files in SharePoint with Power Automate

Step 5: Parse JSON

In this step, we will use the parse JSON action that will return JSON, from this we will use the id of the file to restore.

So click on the Next step and select Parse JSON action, then provide body in the From field from the dynamic content, and in schema click on Generate from Sample, then provide the body from the above step and generate the schema.

Power Automate restore removed files in SharePoint
Power Automate restore removed files in SharePoint

Step 6: Restore the File

Now we will send an HTTP request to restore the file, so click on the Next step and select Send an HTTP request to SharePoint action. Then provide the site address and select method ad Post.

Now in Uri provide the below endpoint API and provide the item id like below, which will automatically add Apply to each action.


_api/site/RecycleBin('')/restore()
MS Flow restore removed files in SharePoint
MS Flow restore removed files in SharePoint

Step 7: Run the Flow

Now click on Save and to run the flow delete a file from the SharePoint Library. So I have deleted the file ‘InviteChristen’.

Microsoft  Flow restore removed files in SharePoint
Microsoft Flow restore removed files in SharePoint

Now you can see flow ran successfully.

How Microsoft  Flow restore removed files in SharePoint
How Microsoft Flow restore removed files in SharePoint

Now you can see the file ‘ InviteChristen’ get restored to the SharePoint Library.

How MS  Flow restore removed files in SharePoint
How MS Flow restore removed files in SharePoint

This is how we can restore the removed files in SharePoint using Power Automate.

Restore all removed Files in Sharepoint with Power Automate

Here we will see how to restore all removed files in Sharepoint with Power Automate.

So we will create a flow that will restore the files from the SharePoint recycle bin(deleted files’ original location should be from particular sites) using Power Automate or Microsoft Flow.

How to Restore all removed files from the recycle bin
Restore all removed files from the recycle bin

In Power Automate, select the Manually triggered Flow, then click on the Next step.

How do i restore all removed files using power Automate
How do I restore all removed files using Power Automate

Next, we will send an HTTP request to SharePoint to get all items in the recycle bin. So select Send an HTTP request to Sharepoint action. Then provide the site address, and Method as Get, then in Uri provide the below API

_api/site/Recyclebin
Restore all removed files from the recycle bin using microsoft Flow
Restore all removed files from the recycle bin using Microsoft Flow

Now click on Save and run the Flow and copy the body of the Send an HTTP request to SharePoint action.

 Microsoft Flow Restore all removed files from the recycle bin
Microsoft Flow Restore all removed files from the recycle bin

Now we will parse the body of the HTTP request to get in the dynamic content. So click on the Next step and select Parse JSON action, Then provide the body in the content from dynamic content. Next, generate the schema from the output of the above step.

Microsoft Flow Restore all removed files in SharePoint
Microsoft Flow Restore all removed files in SharePoint

Now we will restore all files by sending an HTTP request to SharePoint, so click on the next step and select Send an HTTP request to SharePoint action. Then provide the site address, Method as Post. Then provide the below Uri, which will automatically add Apply to each action.

_api/site/RecycleBin('@{items('Apply_to_each')?['Id']}')/restore()
MS Flow Restore all removed files in SharePoint
MS Flow Restore all removed files in SharePoint

Now click on Save and run the flow manually. You can see all deleted files are restored.

Power Automate restore all files in Sharepoint
Power Automate restore all files in Sharepoint

Now you can see all files are restored in the SharePoint library.

How MS Flow Restore all removed files in SharePoint
How MS Flow Restore all removed files in SharePoint

This is how we can restore all removed files in Sharepoint using Power Automate.

Related Power Automate tutorial:

In this Power Automat tutorial, we learned how to restore deleted/removed files in SharePoint with Power Automate or Microsoft Flow. And also we will discuss Power Automate restoring all removed files in Sharepoint.

  • Excellent post. In my case I’m facing a issue because we have a process that delete thousands of entries on a list, so when I try to navigate to https://mycompanyurl/sites/mysite/_api/site/RecycleBin I get an error: “The attempted operation is prohibited because it exceeds the list view threshold”

    We have modified the flow that deletes the entries on the list to fully delete without sending to the recycle bin.

    However, we still have thousands of elements that must be deleted in order we can use the RecycleBin api.

    Is there a way to filter the api request so we can get a lower amount of results that can be managed? Thank you!

  • >