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