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.
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.
Now provide the Flow name and select the trigger ‘When a file is deleted‘ action. Then click on create
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.
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
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'])
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.
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()
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’.
Now you can see flow ran successfully.
Now you can see the file ‘ InviteChristen’ get restored to the SharePoint Library.
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.
In Power Automate, select the Manually triggered Flow, then click on the Next step.
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
Now click on Save and run the Flow and copy the body of the Send an HTTP request to SharePoint action.
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.
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()
Now click on Save and run the flow manually. You can see all deleted files are restored.
Now you can see all files are restored in the SharePoint library.
This is how we can restore all removed files in Sharepoint using Power Automate.
Related Power Automate tutorial:
- Power Automate create table with examples
- How to get days of month in Power Automate
- Power Automate Compose
- How to convert word to pdf using Power Automate
- Power Automate export SharePoint list to excel and send an email
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.
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.
Nice article, how to get schema (nothing happens after clicking it)
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!