0

I am trying to achieve something similar to this: Break inheritance on a folder using REST below but at a level that is one deeper.

I can successfully break inheritance on a Document Set each time a new one gets added to my document library using the following REST call, as per the above answer:

https://sites/mysite/_api/web/GetFolderByServerRelativeUrl('/sites/mysite/DocLib/DocumentSetName')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true)

I can then apply successfully any new permissions that are necessary by making calls in the following format, all well and good:

https://sites/mysite/_api/Web/GetFolderByServerRelativeUrl('/sites/mysite/DocLib/DocumentSetName')/ListItemAllFields/RoleAssignments/AddRoleAssignment(principalid='XXX',roledefid='1073741826')

However there is also a sub folder that gets created underneath the document set that I need to modify the permissions on as follows (this doesn't work but highlights what I am trying to achieve):

https://sites/mysite/_api/web/GetFolderByServerRelativeUrl('/sites/mysite/DocLib/DocumentSetName/My Sub Folder')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true)

https://sites/mysite/_api/Web/GetFolderByServerRelativeUrl('/sites/mysite/DocLib/DocumentSetName/My Sub Folder')/ListItemAllFields/RoleAssignments/AddRoleAssignment(principalid='XXX',roledefid='1073741826')

I can break inheritance and change the unique permissions on the /DocLib/DocumentSetName/My Sub Folder through the UI so I am fairly sure I should be able to do this via REST but am not able to figure out the correct call to make. Searching about hasn't revealed much on this.

UPDATE: If I just have a folder structure in the document library such as DocLib/Folder/My Sub Folder I am able to change the permissions on the /My Sub Folder as expected by using the calls above.

Thanks

1
  • What are you using jQuery ajax or Javascript fetch method? It does not seem you have tried it. – Imir Hoxha Apr 13 at 13:24
0

Try this: You have to use the POST METHOD in both cases:

/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/Testing2/SubFolder1')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=false)

/_api/Web/GetFolderByServerRelativeUrl('Shared%20Documents/Testing2/SubFolder1')/ListItemAllFields/RoleAssignments/AddRoleAssignment(principalid='XXX',roledefid='1073741826')
2
  • Sorry, I should have mentioned that I was using the POST method to make these calls – Bob Apr 13 at 13:31
  • Use the rest api end points above and it should work. Provide the correct user/group Id in the principal property – Imir Hoxha Apr 13 at 13:35
0

After some further testing, it turns out that I wasn't looking in the correct place when looking at the permissions for the sub folder. Quack quack.

I was trying to see who was assigned by using the Permissions button in the ribbon for the given document set sub folder:

enter image description here

When in actual fact I needed to use the Shared With item in the drop down for the sub folder:

enter image description here

It was working as expected all along.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.