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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,851 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,575 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,939 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,935 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenXu-MSFT 19,556 Reputation points Microsoft Vendor
    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.