My replies keep getting held up. I am new at posting here. I'm not sure if it is the text formatting or the api call text. Let's see if this one sticks.
These are the steps I use:
- build a string Variable called permissionUsers.
- add each email address to the string separated by ";" like you would do with the "Grant access to an item or folder" action.
- use a "Compose" Action to split the string: split(variables('permissionUsers'), ';')
- use an "Apply to each" Action on the Outputs of the "Compose" action
- use a "Scope" Action to group the next Actions in case any one of them fails
- in the Scope,
- use a “Send an HTTP request to SharePoint” to get the user id from the email address using getbyemail api call
- use a variable to build the uri to addroleassignment:
- use a “Send an HTTP request to SharePoint” to set the Permission using POST
- after the Scope, add parallel Actions with different "Configure Run After" setting a variable indicating if the Scope completed successfully. Make sure to set the "Configure Run After" for any Actions after the parallel Actions so that the Flow will continue.
Refer to this article for specifics:
https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Power-Automate-and-SharePoint-Permissions/ba-p/656216
The worst thing about the "Grant access to an item or folder" call is that if it fails on one of the users, then it doesn't set the Permission for any of the other users you may have sent it. I also had trouble with the Action when I was testing. In the case where I was providing the email address of a Site Collection Admin, it would not set the explicit Permission (Contribute) for that user. All I could figure what that it would not assign less permission that the user already had. The HTTP request api call did not have any trouble assigning permissions.