web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to get Groups name...
Power Automate
Answered

How to get Groups names of SharePoint sites

(0) ShareShare
ReportReport
Posted on by 14

Hello everyone,

I am looking for a list of groups in a SharePoint site, I know there is the "HTTP request to SharePoint" connector with the code "/_api/web/sitegroups/getbyname('groupname')/users." but that is the problem.

In my project I am not supposed to know the "getbyname('groupname') and since it is an automation stream, I will not go to the site and look for the names of these groups myself.

The goal is that the flow itself will discover the names of the groups in a SharePoint site with a connector, but I never found the answer.

Could you please help me?

Sincerely.

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    Hi @Bucheron,

     

    You can remove the last part (getbyname('groupname')/users) of your code to collect the sitegroups. 

     

    Below is an example to get the LoginName of the first group.

     

    1. Add a Send an HTTP request to SharePoint action and use the following value for the URI field:

    _api/web/sitegroups

     

    http_sitegroups.png

    2. In my example I am using a compose and an expression to extract the LoginName of the first group. 

    outputs('Send_an_HTTP_request_to_SharePoint')?['body']['d']['results'][0]['LoginName']

    firstsitegroupname.png

     

    Hope this helps a bit to get you started?

     

  • Bucheron Profile Picture
    14 on at

    Thanks my savior

    I managed with your code to get the name of the first group.

    Is there a way to tell it to retrieve all existing LoginName on the site by retrieving the number of IDs that exist on the site to replace the [0] through a loop?

    Or is there a simpler way out of my understanding? ^^

  • Verified answer
    Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    Hi @Bucheron 

     

    If you want to retrieve all group names it is probably easier to add a parse json action and than loop through the results of that parse json output results.

     

    1. Add a parse json action. Use the body of your http request to sharepoint action and use the following schema

    {
     "type": "object",
     "properties": {
     "d": {
     "type": "object",
     "properties": {
     "results": {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "__metadata": {
     "type": "object",
     "properties": {
     "id": {
     "type": "string"
     },
     "uri": {
     "type": "string"
     },
     "type": {
     "type": "string"
     }
     }
     },
     "Owner": {
     "type": "object",
     "properties": {
     "__deferred": {
     "type": "object",
     "properties": {
     "uri": {
     "type": "string"
     }
     }
     }
     }
     },
     "Users": {
     "type": "object",
     "properties": {
     "__deferred": {
     "type": "object",
     "properties": {
     "uri": {
     "type": "string"
     }
     }
     }
     }
     },
     "Id": {
     "type": "integer"
     },
     "IsHiddenInUI": {
     "type": "boolean"
     },
     "LoginName": {
     "type": "string"
     },
     "Title": {
     "type": "string"
     },
     "PrincipalType": {
     "type": "integer"
     },
     "AllowMembersEditMembership": {
     "type": "boolean"
     },
     "AllowRequestToJoinLeave": {
     "type": "boolean"
     },
     "AutoAcceptRequestToJoinLeave": {
     "type": "boolean"
     },
     "Description": {},
     "OnlyAllowMembersViewMembership": {
     "type": "boolean"
     },
     "OwnerTitle": {
     "type": "string"
     },
     "RequestToJoinLeaveEmailSetting": {
     "type": "string"
     }
     },
     "required": [
     "__metadata",
     "Owner",
     "Users",
     "Id",
     "IsHiddenInUI",
     "LoginName",
     "Title",
     "PrincipalType",
     "AllowMembersEditMembership",
     "AllowRequestToJoinLeave",
     "AutoAcceptRequestToJoinLeave",
     "Description",
     "OnlyAllowMembersViewMembership",
     "OwnerTitle",
     "RequestToJoinLeaveEmailSetting"
     ]
     }
     }
     }
     }
     }
    }

    parsejson_sitegroups.png

     

    2. Add the results to an apply for each and add for instance a compose within the apply to each to display the loginname field

    results_sitegroupsparsejson.png

     

  • Bucheron Profile Picture
    14 on at

    Thank you very much.

    I just have to do more tests for different uses but this base is already solid, again thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard