Forum Discussion

WeibchenL's avatar
WeibchenL
Copper Contributor
Feb 21, 2024
Solved

Using REST API to set permissions to folders in a SharePoint document library

Hello,  I'm trying to change permissions for specific (sub-)folders in a sharepoint document library. I found to use these at the ending to actually change it: /breakroleinheritance(copyRoleAssig...
  • ganeshsanap's avatar
    Feb 23, 2024

    WeibchenL If you are breaking permissions on "folder" inside the document library, try using server relative URL like below once: 

     

    _api/web/GetFolderByServerRelativeUrl('/sites/MySite/My%20Library/folder/subFolder')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

     

    Or based on item ID of folder: 

     

    _api/web/lists/GetByTitle('Documents')/items(5)/BreakRoleInheritance(CopyRoleAssignments=true, ClearSubscopes=true)

     

    ReferenceSharePoint API BreakRoleBasedInheritance on Folder doesn't seem to work 

     

    For breaking permissions on document library, use URL like: 

     

    _api/web/lists/getByTitle('Documents')/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

     


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources