Power Automate : Adding an O365 Group as Contributor for a Document Library

 Its very straights forward to do this if you have experience working with the 'Send an HTTP request to SharePoint' action before. Here are the things you need to follow :

1. Break the Inheritance for the library so it has unique permissions.

2. Get the Office Group principal ID for the Team ID or Office Group ID

3. Parse JSON - Parse for principal ID

4. Post a roleassignements for the doc library with the principal ID.


1. Breaking Inheritance : Make a http post request to SPOL with this URL assuming Documents is the Doc library where you like to add Contributor permissions.

_api/lists/getByTitle('Documents')/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

2. Get the principal id of the Team/OfficeGroup ID by making a Get request where the variable TeamID is your Team/Group ID and parse the body to extract the Princiapl ID

_api/web/siteusers('c:0o.c|federateddirectoryclaimprovider|@{variables('TeamID')}')

3. Now do a post request to add the principal id as the Contrinutor to the library

_api/lists/getByTitle('Documents')/roleAssignments/addroleassignment(principalId=@@{variables('prinID')}}, roledefId=1073741827)

It does look like the below :



Comments

Popular posts from this blog

Linksys Wireless Connection Failure

The security validation for this page is invalid. Click Back in your Web

Power Apps toPower Automate Error - The input body for trigger 'manual' of type 'Request' did not match its schema definition , the input String does not validate against the date