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.

Inspiration

This tweet from Tom Riha:

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.

The Graph API supports things like $select, $filter & $expand. And this was exactly what we were doing in the original flow.

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.

Flow setup

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.

queryparameters_graphapi_overview

1. Add a Manually trigger a flow action.

manuallytriggeraflow

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.

queryparameters_graphapi

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.

queryparameters_graphapi_test

Happy testing!

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.