0

I have a site accessible by everyone in our organization, inside this site, one library. In this everybody can create folder to upload the files, this is happening through provider hosted app using rest queries. Once user creates the folder, what i am trying to do is breakRoleInheritance on this folder and assign role only for creator of this folder and another two users. Braking the role inheritance and assigning the role is being done by rest queries as below : https://my.sharepoint.com/sites/Service_Request_Test/_api/web/GetFolderByServerRelativeUrl('RA_PIServiceRequestDocLib/641')/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

https://my.sharepoint.com/sites/Service_Request_Test/_api/web/GetFolderByServerRelativeUrl('RA_PIServiceRequestDocLib/641')/roleassignments/addroleassignment(principalid=1156,roleDefId=1073741828)

When i run there queries, i get the below error message as "Cannot find resource for the request breakroleinheritance" and "Cannot find resource for the request roleassignment" respectively.

Here Service_Request_Test is the site, RA_PIServiceRequestDocLib is document library, 614 is the folder.

Kindly request you help on this.

1 Answer 1

2

Change the breakroleinheritance rest endpoint from

/_api/web/GetFolderByServerRelativeUrl('/<library>/<folder url>')/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

to the following rest endpoint

/_api/web/GetFolderByServerRelativeUrl('/<library>/<folder url>')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

Also, change the addroleassignment rest endpoint from

/_api/web/GetFolderByServerRelativeUrl('/<library>/<folder url>')/roleassignments/addroleassignment(principalid=<User or group id>,roleDefId=<Role definition id>)

to the following rest endpoint

/_api/web/GetFolderByServerRelativeUrl('/<library>/<folder url>')/ListItemAllFields/roleassignments/addroleassignment(principalid=<User or group id>,roleDefId=<Role definition id>)

Files and folders rest api for SharePoint reference:

https://msdn.microsoft.com/en-us/library/office/dn450841.aspx

https://gnanasivamgunasekaran.wordpress.com/2016/06/10/sharepoint-rest-api-url-for-accessing-working-in-list-document-libraries-search-and-user-profile-property/

1
  • Thanks you for you response. breakInheritance rest endpoint is going through. But i am getting below error for addroleassignment rest endpoint "mysite.sharepoint.com/sites/Test_Doc_Lib/_api/web/…. Kindly request you to help on this. Error: {error: {code: "-2147024809, System.ArgumentException",…}} message: {lang: "en-US", value: "Value does not fall within the expected range."}
    – Nagnath
    Jan 3, 2018 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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