Get All Site Admins in MS Flow

SharePoint REST API from MS Flow


In this post, I’ll demonstrate how to run any SharePoint REST API directly from MS Flow. MS FLow already provides lots of action cards OOTB. For ex, create a list, delete a list, etc. However, it doesn’t contain action cards for, let’s say, every possible operation within SharePoint. Microsoft has intentionally provided, only the commonly used actions to MS Flow. This also makes sense because, one of the key attribute of MS Flow lies in its simplicity and how, even a business user can perform simple tasks on their own. Rather than having the users lost in a plethora of choices, they are presenting them with only a list of commonly used tasks. For everything else, there’s REST API.

In this post, I’ll perform one of the admin related task. I will fetch a list of all the current site collection administrators whenever this flow is triggered. This cannot be achieved using OOTB actions. So, I’ll be running a SharePoint REST API to achieve the same.

SharePoint REST API from MS Flow

  • I have created a new flow from blank, GetAllSiteAdmins. The trigger of this flow is set to SharePoint – For a selected item. A selected item trigger let’s you trigger a flow on a particular item.

    Selected Item Flow
    Selected Item Flow
  • To this flow, add a new action, Send an HTTP request to SharePoint. This is the action, which is responsible for making REST calls to SharePoint.

    SharePoint REST
    SharePoint REST
  • To fetch the list of all the Site Administrators, we have to execute the following REST call,
    /_vti_bin/ListData.svc/UserInformationList?$select=Name,WorkEmail&$filter=IsSiteAdmin eq true

    Set the above call to the Uri property of this action.

    SharePoint Site Collection Administrators
    SharePoint Site Collection Administrators
  • As we have set the accept parameter to JSON, we’ll need to parse this JSON response now. To do it, I’ve added a new action, Parse JSON.

    MS Flow: Parse JSON
    Parse JSON
  • The content property of the Parse JSON action is set to the response body of its predecessor. To generate a schema, use the following sample payload.
      "d": {
        "results": [
            "__metadata": {
              "uri": "",
              "etag": "W/\"5\"",
              "type": "Microsoft.SharePoint.DataService.UserInformationListItem"
            "Name": "Piyush-TeamSite",
            "WorkEmail": ""
  • Initialize an array variable. We’ll add the names of all the administrators to this array.

    Initialize Array
    Initialize Array
  • Add an, Apply to each action. Since, there can be multiple administrators, we need to recurse over all of their names.

    MS Flow: Apply to each
    Apply to each
  • Append to our array variable, email ids of all the admins.
    concat(items('Apply_to_each')?['Name'], ' : ', items('Apply_to_each')?['WorkEmail'])

    MS Flow: Append to array
    Append to array
  • Add the names of all the admins in a new line.
    join(variables('adminAry'), '<br />')

    MS Flow: Compose
  • Finally, send this list in an email.

    MS Flow: Send Admin list over email
    Send Admin list over email

Run the Flow

On running this flow, it’ll send me the names and email addresses of all the site collection administrators of the given site. In my case, there’s only 1 admin.

Selected Item Flow
Selected Item Flow
List of Site Collection Administrators
List of Site Collection Administrators

Key Takeaways

  • MS Flows, itself is pretty useful. Coupled with SharePoint REST APIs, it provides us with options to automate various tasks.
  • Previously, we were required to Register App in SharePoint, get access tokens, and then only make HTTP requests to SharePoint. This has been greatly simplified with the introduction of the action card, Send an HTTP Request to SharePoint.

One thought on “SharePoint REST API from MS Flow

  1. Hello, where do you get this information to connect to the different components as for example
    – recycle bin, second stage recycle bin
    – primary owner, co owners (site collection admins)
    – site collection storage quota
    – sharing settings in sharepoint admin center

    I want to use the HTTP premium actions or triggers or the Send an HTTP request to SharePoint action to complete administrative tasks. Could you provide me link that has an overview of all options available (some sort of reference)?

    Thanks in advance!!!! great blog post!!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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