In this article, we will see how to remove the unique permissions from the SharePoint list or library items.

SharePoint-2013-Hosting
Use Case

In my Documents library, I have a lot of files with unique permissions. I want to remove these unique permissions with the help of REST API. You can see that, I have added 3 files with unique permissions in the Documents library.

Script to remove unique permissions using REST API

We will call the function in the loop. Here variables names i represent the item ID. As we want to remove all the unique permissions from the library, we can start the ID from 1. In the below script, we are calling the myFunction in the loop.

We are also checking for the error code 400 in the error block, which represents that the item was deleted.

This will remove the unique permissions from all the files from the document library.