Managing permissions in SharePoint can be a bit complex, especially when dealing with custom permission groups. Fortunately, you don’t have to manually search through the interface for this information—Power Automate and SharePoint APIs can help you retrieve these details automatically.
In this blog post, I will walk you through how to retrieve custom permission Group IDs and names in SharePoint using Power Automate and the SharePoint REST API.
To get the all SharePoint site groups we use the following REST API-
/_api/web/sitegroups.
Flow Design-
In this flow, when you use the Parse JSON action and attempt to retrieve the group ID inside the loop, you may find that the Group Membership ID is blank. This happens because the Id is defined within another array block. To resolve this, you need to fetch the Id separately using the following expression:
items(‘Apply_to_each’)?[‘Id’]
Output
To retrieve the SharePoint custom permission level role definition IDs and name, you typically append the
_api/web/roledefinitions
to the SharePoint site URL. This will return the output in XML format, providing detailed information about the role definitions and associated permissions for the groups.
Example– https://gopenly.sharepoint.com/sites/<sitename>/_api/web/roledefinitions
XML output
Note: To view the XML output in a proper JSON format, you can use any online XML to JSON converter. I personally recommend using this one.
Retrieving the custom permission level role definition is essential, as it specifies the permissions granted to a SharePoint folder or item. Once you have this information, you can automate the assignment of permissions to files and folders using Power Automate flows.