There are no actions yet available to set permissions on a Sharepoint List Item. we need to use Rest APIs through Send an HTTP Request to SharePoint action. In this article, we shall go through all the Rest APIs we are going to use for permissions.
We can do only one role assignment to one user / group at a time. As there would be multiple Rest API calls, we use Batch Requests to achieve this in single call.
The syntax to batch call is as below,
Using above format, we can merge all the role assignments to one batch call by using Send an HTTP request to Sharepoint.
Here, create 2 GUIDs to use for Batch and Changeset, expression is guid()
then, use HTTP request action as in below image
- First, we need to break inheritance of the Item / Sharepoint object, below is the Post callbreakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)
- CopyRoleAssignments: this will maintain existing permissions. If set to false, clears existing assignments / permissions
- clearSubscopes: this is used for items / objects below current object, i.e., if we are breaking permissions on List, this property controls for list items.
- Next, we need to assign roles, this could to be a user / group. below is the post call./roleassignments/addroleassignment(principalid=,roleDefId=)
- Principalid: It is the ID of User / SP Group we are going to assign. We can get IDs of user using service /_api/web /siteusers and for group, /_api/web/sitegroups
- roleDefId: Its is the ID of Permission Role we want to assign to. We can get Role IDs, using the service /_api/web/roledefinitions
We can do only one role assignment to one user / group at a time. As there would be multiple Rest API calls, we use Batch Requests to achieve this in single call.
The syntax to batch call is as below,
--BatchID
content-type: multipart/mixed; boundary=ChangesetID
Host:
Content-Transfer-Encoding: binary
--ChangesetID
content-type: application/http
Content-Transfer-Encoding: binary
<<service call>> HTTP/1.1
--ChangesetID
content-type: application/http
Content-Transfer-Encoding: binary
<<service call>> HTTP/1.1
--ChangesetID--
--BatchID--
Using above format, we can merge all the role assignments to one batch call by using Send an HTTP request to Sharepoint.
Here, create 2 GUIDs to use for Batch and Changeset, expression is guid()
then, use HTTP request action as in below image
No comments:
Post a Comment