List M365 Group owners with Graph API query parameters
I use the Graph API a lot in Power Automate. Today I want to point out how powerful the usage of query parameters can be. This article demonstrates how you can list all the e-mail addresses of owners of a Microsoft 365 Group with one action.
This tweet from Tom Riha:
— Tom Riha | Microsoft MVP (@riha_tom) June 12, 2022
Like always this was a great blog about listing Microsoft 365 Group owners with some great techniques and tricks in it. Tom has a lot of great content about Power Automate on his site, definitely check it out.
Graph API Query parameters
When I was testing Tom’s solution I thought I might be able to simplify things by using Graph API query parameters.
But before you get all excited. Not every query parameter is supported for every resource type or method.
Always check before you start building your query. In this instance we would be interested in the List Groups method. Luckily this method supports $select, $filter & $expand.
In this example we are trying to retrieve the list of e-mail addresses of owners of the IT group. We are using a $filter on the displayName. With an $expand we are retrieving the owners. And with a nested $select we are retrieving the mail property of the owners.
1. Add a Manually trigger a flow action.
2. Add a Send an HTTP request (Office 365 Groups Connector)
Note: the question mark character after the groups needs to be escaped with a forward slash character. This is a small gotcha for this specific action. In actions like HTTP this is not needed.
a. Use a the URI below:
b. Select the GET method
That is it for the setup of this example. The response of the action should look something like below.