Forum Discussion
Using REST API to set permissions to folders in a SharePoint document library
- 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)
Reference: SharePoint 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.
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)
Reference: SharePoint 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.
- WeibchenLFeb 23, 2024Copper ContributorThank you very much, as I said beneath the other post, I could bake you a cake!
I don't know how it wroked now after i tred so many combinations and stuff, but it did with your help