“Is there a way to set permissions for the whole SharePoint list after creation by a Power Automate flow?”
All (both) the SharePoint permission actions in Power Automate are designed to work with items or documents. You can stop sharing item or a file, and then assign permissions to specific users or M365 groups. But what if you want to go one level higher? Reduce permissions not only on an item or a file, but on a whole list that you just created?
As many times before, you’ll need an HTTP request.
Remove list permissions
It’s the same HTTP requests as when you manage item / file permissions with a small difference in the url. Instead of referencing the specific item, you stop at the list level.
For example, to break permission inheritance:
Method: POST
Uri:
_api/web/lists/getByTitle('<ListName>')/breakroleinheritance(true)
instead of
_api/web/lists/getByTitle('<ListName>')/items(<FolderID>)/breakroleinheritance(true)
List all users with permissions:
Method: POST
Uri:
_api/web/lists/getByTitle('<ListName>')/roleassignments
Remove user permissions:
Method: POST
Header:
{
"X-HTTP-Method": "DELETE"
}
Uri:
_api/web/lists/getByTitle('<ListName>')/roleassignments(<PrincipalId>)
Add list permissions
The same applies also when you want to assign some user permissions back:
Method: POST
Uri:
_api/lists/getByTitle('<listName>')/roleAssignments/addRoleAssignment(PrincipalId=<groupID>,roleDefId=<roleID>)
Restore list permissions
And also to restore original permissions from the site level:
Method: POST
Uri:
_api/Web/lists/getByTitle('<listName>')/ResetRoleInheritance()
Summary
As you can see, you can manage SharePoint list permissions with Power Automate in the same way as list and file permissions – if you stick to the HTTP requests. All you have to do is skip the item / file part from the request uri and it’ll manage permissions on the whole list or library.
Can you show the configuration of the “parse JSON” action, please?
Hello David,
you can get the configuration if you add the HTTP actions in a flow, run it, and take the whole output of the 2nd http request (…/roleassignments) as the sample payload as explained here: https://tomriha.com/where-do-i-get-schema-for-the-parse-json-action-in-power-automate/
Hello, I’ve followed this flow, but my flow keeps failing the apply to each. I get an error code that the “result” is of Type ‘Null’. the result must be a valid array. I’m not sure what I’ve missed.
Hello Darla,
the ‘results’ input of the Apply to each is most probably empty, I’d check the HTTP requests if they return some other value than [].