How To Get Users From A SharePoint Group In MS Flow

Introduction

 
In this article, I’m going to explain how to retrieve all users with their properties from a SharePoint group using MS Flow.
 

Procedure Overview

  • Create a flow with any trigger like SharePoint List item created or modified or click on button from PowerApps.
  • Then, create some string variables to predefine the SharePoint Site Address, Group Name, SharePoint List Name, and an array variable for group users, etc.
  • Then, use a ‘Send HTTP Request to SharePoint’ with the GET method as a next action.
  • Then, set the output to an array variable.

Procedure

 
Step 1
 
Create a flow with a trigger called "When an item is created or modified in SharePoint" as below.
 
How To Get Users From A SharePoint Group In MS Flow
 
Step 2
 
Now, initialize two string variables for Site address and URI for SharePoint Group. Then, set one array variable for users from the group as shown below.
 
How To Get Users From A SharePoint Group In MS Flow
 
Where the value in the first variable is SharePoint Site Address, then the value in the URI is for the SharePoint Group.
 
Syntax
 
/_api/web/sitegroups/getbyname(‘Your Group Name’)/users
 
Then, let us set the last variable for all users from the respected group. I have named it as Project Managers.
 
Step 3
 
Now, send an HTTP request to SharePoint with the above-predefined variables to get users from the respected group, as shown below.
 
How To Get Users From A SharePoint Group In MS Flow
 
Here, the two variables are predefined in the above step 2.
 
Step 4
 
Now, set the pre-initialized Array variable with output from the above HTTP request as below.
 
How To Get Users From A SharePoint Group In MS Flow
 
Here, the ProjectManagers is Preinitialized Array Variable and the Syntax for the Value is from the above HTTP request.
 
Syntax
 
body('Send_an_HTTP_request_to_SharePoint_3')['d']['results']
 
Hence, we have fetched all the users from the respected SharePoint group in the above variable ProjectManagers. So, you can loop the array and use every individual property as per your requirement from the Array variable.
 

The Overview of the Flow

 
How To Get Users From A SharePoint Group In MS Flow
 
How To Get Users From A SharePoint Group In MS Flow
 
How To Get Users From A SharePoint Group In MS Flow
 
How To Get Users From A SharePoint Group In MS Flow

Conclusion

 
When we want to fetch a user’s properties from a SharePoint group in the flow, use HTTP request with required strings as variables and set the output to an array variable then use the output as per your requirement as explained in above steps. I hope this makes sense.
 
Thank you!