Forum Discussion

WeibchenL's avatar
WeibchenL
Copper Contributor
Feb 21, 2024

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(copyRoleAssignments=false,clearSubscopes=true)
  • /roleassignments/addroleassignment(principalid=’5‘, roleDefId=1073741827)

However, I can't seem to find out how to put the uri so that it works.


Can anyone help me?

  • 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.

  • 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.

    • WeibchenL's avatar
      WeibchenL
      Copper Contributor
      Thank 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

Resources