0

We are using SharePoint Online. I am planning to add a flow to send out an email notification whenever a new page is added to the site.

To do that, I need the list of members of that site cause I don't want to send it to everyone or anyone.

I am unable to retrieve the group members through REST API. When I fire the following REST call, I am getting the response as follows, but not the actual members and their email addresses

https://dhdigitalcoin.sharepoint.com/sites/OpenSourceTechTalk/_api/web/sitegroups/getbyname('Open%20Source%20Tech%20Talk%20Members')/users


<entry>
<id>https://dhdigitalcoin.sharepoint.com/sites/OpenSourceTechTalk/_api/Web/GetUserById(7)</id>
<category term="SP.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link rel="edit" href="Web/GetUserById(7)"/>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Alerts" type="application/atom+xml;type=feed" title="Alerts" href="Web/GetUserById(7)/Alerts"/>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Groups" type="application/atom+xml;type=feed" title="Groups" href="Web/GetUserById(7)/Groups"/>
<title/>
<updated>2019-06-03T12:47:56Z</updated>
<author>
<name/>
</author>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">7</d:Id>
<d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
<d:LoginName>c:0o.c|federateddirectoryclaimprovider|92b9f118-885e-4c23-a103-de7ce46d7421</d:LoginName>
<d:Title>Open Source Tech Talk Members</d:Title>
<d:PrincipalType m:type="Edm.Int32">4</d:PrincipalType>
<d:Email>OpenSourceTechTalk@xxx.onmicrosoft.com</d:Email>
<d:Expiration/>
<d:IsEmailAuthenticationGuestUser m:type="Edm.Boolean">false</d:IsEmailAuthenticationGuestUser>
<d:IsShareByEmailGuestUser m:type="Edm.Boolean">false</d:IsShareByEmailGuestUser>
<d:IsSiteAdmin m:type="Edm.Boolean">false</d:IsSiteAdmin>
<d:UserId m:null="true"/>
<d:UserPrincipalName m:null="true"/>
</m:properties>
</content>
</entry>

Is there a way I can retrieve the actual members?

Am I taking the right approach towards building email notifications?

  • Do you want to get all site users or users from particular SharePoint group?? – Ganesh Sanap Jun 3 at 12:59
  • All site users.. – Pavan Andhukuri Jun 3 at 13:07
4

If you want to get all the users in your SharePoint site you can use :

/_api/web/siteusers?

Update:

Try using below endpoint to get the Site Members from Members group:

_api/Web/SiteGroups/GetByName('SiteName Members')/users

To get the specific property for user, you can add $select query as given below:

_api/Web/SiteGroups/GetByName('SiteName Members')/users?$select=Email,Id

You can get the following user properties using this endpoint:

  1. Email
  2. Groups
  3. Id
  4. IsHiddenInUI
  5. IsSiteAdmin
  6. LoginName
  7. PrincipalType
  8. Title
  9. UserId

You can find everything related to Users, groups, and roles using REST API in below article(Must visit, this is a very helpful article): Users, groups, and roles using REST API.

  • When I fire this, I am getting the email addresses of visitors as well.. which I don't want.. – Pavan Andhukuri Jun 3 at 13:09
  • try using members group...group name will be like SiteName<space>Members. – Ganesh Sanap Jun 3 at 13:15
  • Have you tried this?? – Ganesh Sanap Jun 3 at 13:37
  • I am using the members group only.. And When I fire your updated result, it is indeed selecting only the email address but it is still not giving me the individual members. Instead, it is just returning the email OpenSourceTechTalk@xxx.onmicrosoft.com – Pavan Andhukuri Jun 4 at 9:59
  • have you used /users? You can go the group you want to fetch and check if any users are added there. – Ganesh Sanap Jun 4 at 10:12
0

You are getting back the actual users, just not their email address. You need to select Email, like:

_spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups/getbyname('Open%20Source%20Tech%20Talk%20Members')/users?$select=Email"

This will get back a response like:

{
    value: [
        0: {
               Email: "mcsheaj@domain.com"
        },
        length: 2
    ]
}

assuming you set an accept header like:

headers: {
    'accept': 'application/json;odata=nometadata'
}
  • The issue is that the users are not the ones who are members of the group. There are actually two users as members of the group and sharepoint is returning only one entry which is again with a grouped email address. – Pavan Andhukuri Jun 4 at 10:00
  • Ok, I did misunderstand your problem a bit, but what you want is something I've been looking for since 2007 and it just doesn't exist, at least not in SharePoint. You'd need a SharePoint API that expands the AD security group, and there isn't one. If there is a way to expand a group by talking directly to AD from flow, that would be the way to go, but using the SharePoint APIs there is no way to tell what users are members of a SharePoint group indirectly (i.e. granted through membership in an AD security group). – Joe McShea Jun 5 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.