Microsoft Flow - Get Users From SharePoint Group Using The API

Recently, I was asked to create a Flow for a customer which had some approvals, notifications and some other stuff in it. One of the scenario’s I had to implement was to send a notification to SharePoint group users.

Flow has an action called ‘Send an HTTP request to SharePoint’. With this action you can call the SharePoint REST API and perform all sorts of operations.

With this API, you can get all users in a specific SharePoint Group with the following REST call,

https://<siteurl>/_api/web/sitegroups/getbyname('<groupname>')/users

Steps
  1. Add the 'Send an HTTP request to SharePoint' action and configure it so that you call the API as stated above.

    Send an HTTP request to SharePoint

  2. Initialize variable 'users' as array type and the value should look like this,

    body('Send_an_HTTP_request_to_SharePoint')['d']['results'].

    Initialize variable 'user'

  3. Initialize variable 'i' as Integer type with Value 0.

  4. Initialize variable 'user' as string type.

    Initialize variable 'user'

  5. Add Apply to each and add 'users' in output which we created for array.

  6. Add append to string variable inside and apply to each. Select 'user' as Name and Value as below,

    concat(variables('users')[variables('i')]['Email'],';')

    Select 'user'

  7. Add increment variable inside and apply to each. Select 'i' as Name and Value as 1 as shown in img above.
Finally we are done and you can use 'user' variable in your 'Send Email' which will contain all users inside the group.