Get Group ID by SharePoint Site Url

SharePoint Online Team sites can have Microsoft 365 Groups associated with them. In this article I will show you how you can retrieve the Group ID of the related Microsoft 365 Group in a Power Automate flow.

Inspiration

This question from owidiuz:

How do i get the GroupID of an SP site owned by a group. I’m mentioning that I can’t go to Site collection-> Site Settings->People and Group, because it doesn’t appear to me. Is there another way to get the ID , like from flow. i can see that the “List group members” is asking for the groupid and I can find it in the dropdown, but I need to use that ID in another Step.

Power Users Community thread: Get the groupID for from sharepoint group

selectgroupid_huh

Interface

In the interface you could find this Group Id in at least a couple of different places.

Option A. Go the Planner Plan of the related group. The GroupId should be in the address bar.
Option B. In the Microsoft Admin Center go to Teams & groups > Active teams & groups > Find your group and click on the Name. The GroupId should be in the address bar.

However, we want to dynamically retrieve the Group Id value.

Allproperties method

You could use the allproperties method from the REST API to retrieve the Group ID value. JanardhanaVedham-MSFT has written a nice forum post on Microsoft Q&A about this option.

With a $select query parameter and the GroupId property this is a great way of retrieving the Id value. We can use that in a Send an HTTP request to SharePoint action.

Flow setup

selectgroupid03

1. Add a Manually trigger a flow action.

manuallytriggeraflow

2. Add a Send an HTTP request to SharePoint action.

selectgroupid

a. Select your preferred site in the Site Address, this would be the site from which you want to retrieve the Group Id value.
b. Use the GET method
c. Use the URI from the code snippet below

d. Use the Headers from the code snippet below

3. List group members.

selectgroupid02

a. Use the expression from the code snippet below as a custom value for the Group Id field

That is it for the setup of this example.

Happy testing!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

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