Not able to get all available user_group uisng rest api

asked 2021-04-20T12:48:50.317+00:00
Pankaj Kumar 21 Reputation points

Hi Team,

we are using rest api to get all user_group
rest api = <sp_site>/_api/web/sitegroups

Using this API, we are getting few user_group only,
but when we are trying to assign asl for any document or directory through SP site, that time we are getting all available user_group.

Regards,
Pankaj Kumar

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
5,968 questions
No comments
{count} votes

3 answers

Sort by: Most helpful
  1. answered 2021-04-21T02:24:51.383+00:00
    Michael 17,861 Reputation points

    Hi @Pankaj Kumar ,

    The api call /_api/web/sitegroups is to get all sharepoint groups in the site.

    If you want to get all the users in your Sharepoint site you can use: /_api/web/siteusers.

    This article would be helpful to you: https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn531432(v=office.15)?redirectedfrom=MSDN#user-resource


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. answered 2021-04-21T11:40:15.807+00:00
    Pankaj Kumar 21 Reputation points

    When are calling rest API = _api/web/sitegroups

    output =
    <content type="application/xml">
    <m:properties>
    <d:Id m:type="Edm.Int32">5</d:Id>
    <d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
    <d:LoginName>QA_Automation2 Members</d:LoginName>
    <d:Title>QA_Automation2 Members</d:Title>
    <d:PrincipalType m:type="Edm.Int32">8</d:PrincipalType>
    <d:AllowMembersEditMembership m:type="Edm.Boolean">true</d:AllowMembersEditMembership>
    <d:AllowRequestToJoinLeave m:type="Edm.Boolean">false</d:AllowRequestToJoinLeave>
    <d:AutoAcceptRequestToJoinLeave m:type="Edm.Boolean">false</d:AutoAcceptRequestToJoinLeave>
    <d:Description m:null="true" />
    <d:OnlyAllowMembersViewMembership m:type="Edm.Boolean">false</d:OnlyAllowMembersViewMembership>
    <d:OwnerTitle>QA_Automation2 Owners</d:OwnerTitle>
    <d:RequestToJoinLeaveEmailSetting></d:RequestToJoinLeaveEmailSetting>
    </m:properties>
    </content>
    <content type="application/xml">
    <m:properties>
    <d:Id m:type="Edm.Int32">3</d:Id>
    <d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
    <d:LoginName>QA_Automation2 Owners</d:LoginName>
    <d:Title>QA_Automation2 Owners</d:Title>
    <d:PrincipalType m:type="Edm.Int32">8</d:PrincipalType>
    <d:AllowMembersEditMembership m:type="Edm.Boolean">false</d:AllowMembersEditMembership>
    <d:AllowRequestToJoinLeave m:type="Edm.Boolean">false</d:AllowRequestToJoinLeave>
    <d:AutoAcceptRequestToJoinLeave m:type="Edm.Boolean">false</d:AutoAcceptRequestToJoinLeave>
    <d:Description m:null="true" />
    <d:OnlyAllowMembersViewMembership m:type="Edm.Boolean">false</d:OnlyAllowMembersViewMembership>
    <d:OwnerTitle>QA_Automation2 Owners</d:OwnerTitle>
    <d:RequestToJoinLeaveEmailSetting></d:RequestToJoinLeaveEmailSetting>
    </m:properties>
    </content>
    <content type="application/xml">
    <m:properties>
    <d:Id m:type="Edm.Int32">4</d:Id>
    <d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
    <d:LoginName>QA_Automation2 Visitors</d:LoginName>
    <d:Title>QA_Automation2 Visitors</d:Title>
    <d:PrincipalType m:type="Edm.Int32">8</d:PrincipalType>
    <d:AllowMembersEditMembership m:type="Edm.Boolean">false</d:AllowMembersEditMembership>
    <d:AllowRequestToJoinLeave m:type="Edm.Boolean">false</d:AllowRequestToJoinLeave>
    <d:AutoAcceptRequestToJoinLeave m:type="Edm.Boolean">false</d:AutoAcceptRequestToJoinLeave>
    <d:Description m:null="true" />
    <d:OnlyAllowMembersViewMembership m:type="Edm.Boolean">false</d:OnlyAllowMembersViewMembership>
    <d:OwnerTitle>QA_Automation2 Owners</d:OwnerTitle>
    <d:RequestToJoinLeaveEmailSetting></d:RequestToJoinLeaveEmailSetting>
    </m:properties>
    </content>
    <content type="application/xml">
    <m:properties>
    <d:Id m:type="Edm.Int32">19</d:Id>
    <d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
    <d:LoginName>SharingLinks.040a2b23-abff-4089-ad97-53272ef5c988.Flexible.05b1bf35-5712-422a-a4d4-023cb4951c48</d:LoginName>
    <d:Title>SharingLinks.040a2b23-abff-4089-ad97-53272ef5c988.Flexible.05b1bf35-5712-422a-a4d4-023cb4951c48</d:Title>
    <d:PrincipalType m:type="Edm.Int32">8</d:PrincipalType>
    <d:AllowMembersEditMembership m:type="Edm.Boolean">false</d:AllowMembersEditMembership>
    <d:AllowRequestToJoinLeave m:type="Edm.Boolean">false</d:AllowRequestToJoinLeave>
    <d:AutoAcceptRequestToJoinLeave m:type="Edm.Boolean">false</d:AutoAcceptRequestToJoinLeave>
    <d:Description>This group is for Flexible sharing links on item 'DocumentLibrary_2021_03_11_10_20_00_911/newfold123_99'</d:Description>
    <d:OnlyAllowMembersViewMembership m:type="Edm.Boolean">true</d:OnlyAllowMembersViewMembership>
    <d:OwnerTitle>System Account</d:OwnerTitle>
    <d:RequestToJoinLeaveEmailSetting m:null="true" />
    </m:properties>
    </content>

    We are getting only 4 groups but
    when we are checking groups through SP site,

    it is showing different groups also (ACL Testing, can see in above screen shot )
    but we are not getting this group in rest api call

    No comments

  3. answered 2021-04-21T11:52:56.843+00:00
    Pankaj Kumar 21 Reputation points

    89920-sp-group.jpgWhen are calling rest API = _api/web/sitegroups

    output =
    <content type="application/xml">
    <m:properties>
    <d:Id m:type="Edm.Int32">5</d:Id>
    <d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
    <d:LoginName>QA_Automation2 Members</d:LoginName>
    <d:Title>QA_Automation2 Members</d:Title>
    <d:PrincipalType m:type="Edm.Int32">8</d:PrincipalType>
    <d:AllowMembersEditMembership m:type="Edm.Boolean">true</d:AllowMembersEditMembership>
    <d:AllowRequestToJoinLeave m:type="Edm.Boolean">false</d:AllowRequestToJoinLeave>
    <d:AutoAcceptRequestToJoinLeave m:type="Edm.Boolean">false</d:AutoAcceptRequestToJoinLeave>
    <d:Description m:null="true" />
    <d:OnlyAllowMembersViewMembership m:type="Edm.Boolean">false</d:OnlyAllowMembersViewMembership>
    <d:OwnerTitle>QA_Automation2 Owners</d:OwnerTitle>
    <d:RequestToJoinLeaveEmailSetting></d:RequestToJoinLeaveEmailSetting>
    </m:properties>
    </content>
    <content type="application/xml">
    <m:properties>
    <d:Id m:type="Edm.Int32">3</d:Id>
    <d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
    <d:LoginName>QA_Automation2 Owners</d:LoginName>
    <d:Title>QA_Automation2 Owners</d:Title>
    <d:PrincipalType m:type="Edm.Int32">8</d:PrincipalType>
    <d:AllowMembersEditMembership m:type="Edm.Boolean">false</d:AllowMembersEditMembership>
    <d:AllowRequestToJoinLeave m:type="Edm.Boolean">false</d:AllowRequestToJoinLeave>
    <d:AutoAcceptRequestToJoinLeave m:type="Edm.Boolean">false</d:AutoAcceptRequestToJoinLeave>
    <d:Description m:null="true" />
    <d:OnlyAllowMembersViewMembership m:type="Edm.Boolean">false</d:OnlyAllowMembersViewMembership>
    <d:OwnerTitle>QA_Automation2 Owners</d:OwnerTitle>
    <d:RequestToJoinLeaveEmailSetting></d:RequestToJoinLeaveEmailSetting>
    </m:properties>
    </content>
    <content type="application/xml">
    <m:properties>
    <d:Id m:type="Edm.Int32">4</d:Id>
    <d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
    <d:LoginName>QA_Automation2 Visitors</d:LoginName>
    <d:Title>QA_Automation2 Visitors</d:Title>
    <d:PrincipalType m:type="Edm.Int32">8</d:PrincipalType>
    <d:AllowMembersEditMembership m:type="Edm.Boolean">false</d:AllowMembersEditMembership>
    <d:AllowRequestToJoinLeave m:type="Edm.Boolean">false</d:AllowRequestToJoinLeave>
    <d:AutoAcceptRequestToJoinLeave m:type="Edm.Boolean">false</d:AutoAcceptRequestToJoinLeave>
    <d:Description m:null="true" />
    <d:OnlyAllowMembersViewMembership m:type="Edm.Boolean">false</d:OnlyAllowMembersViewMembership>
    <d:OwnerTitle>QA_Automation2 Owners</d:OwnerTitle>
    <d:RequestToJoinLeaveEmailSetting></d:RequestToJoinLeaveEmailSetting>
    </m:properties>
    </content>
    <content type="application/xml">
    <m:properties>
    <d:Id m:type="Edm.Int32">19</d:Id>
    <d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
    <d:LoginName>SharingLinks.040a2b23-abff-4089-ad97-53272ef5c988.Flexible.05b1bf35-5712-422a-a4d4-023cb4951c48</d:LoginName>
    <d:Title>SharingLinks.040a2b23-abff-4089-ad97-53272ef5c988.Flexible.05b1bf35-5712-422a-a4d4-023cb4951c48</d:Title>
    <d:PrincipalType m:type="Edm.Int32">8</d:PrincipalType>
    <d:AllowMembersEditMembership m:type="Edm.Boolean">false</d:AllowMembersEditMembership>
    <d:AllowRequestToJoinLeave m:type="Edm.Boolean">false</d:AllowRequestToJoinLeave>
    <d:AutoAcceptRequestToJoinLeave m:type="Edm.Boolean">false</d:AutoAcceptRequestToJoinLeave>
    <d:Description>This group is for Flexible sharing links on item 'DocumentLibrary_2021_03_11_10_20_00_911/newfold123_99'</d:Description>
    <d:OnlyAllowMembersViewMembership m:type="Edm.Boolean">true</d:OnlyAllowMembersViewMembership>
    <d:OwnerTitle>System Account</d:OwnerTitle>
    <d:RequestToJoinLeaveEmailSetting m:null="true" />
    </m:properties>
    </content>

    We are getting only 4 groups but
    when we are checking groups through SP site,

    it is showing different groups also (ACL Testing, can see in above screen shot )
    but we are not getting this group in rest api call

    No comments