How can I fetch the users who are in SharePoint default group like owners, members and visitors.Using this endpoint site/siteid/lists/User Information List/items?expand=field i get all the members. but cant differentiate in which group they belong to

Abhijith Chandrababu 0 Reputation points
2024-03-05T10:30:30.9533333+00:00

Using this endpoint site/{siteid}/lists/User Information List/items?expand=field. i am getting the response as the default groups and the users that have access to sharepoint site. But am unbale to determine the in which group they belong to. like Owners, visitors or memebers. i wanna know in wwhich group they belong to?

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenXu-MSFT 24,941 Reputation points Moderator
    2024-03-06T05:55:46.3333333+00:00

    Hi @Abhijith Chandrababu,

    To fetch the users who are in SharePoint default groups like Owners, Members, and Visitors, you can use the SharePoint REST API endpoint /_api/web/sitegroups/getbyname('Group Name')/users. Replace 'Group Name' with the name of the group you want to fetch users for. For example, to fetch users in the Owners group, use the endpoint /_api/web/sitegroups/getbyname('Owners')/users. You can also use the endpoint /_api/web/sitegroups to get information about all the groups in the site, including their ID and name.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.