Method for Limiting Sites Using "Sites.Selected"

Ren Higashida 45 Reputation points
2024-10-03T10:30:02.16+00:00

Background:

Currently, we are using the Graph API's "Search for sites" function to retrieve a list of SharePoint sites. Detailed documentation can be found here: Search for sites - Microsoft Graph.
In the future, we plan to implement site limitations using "Sites.Selected." However, the documentation for "Search for sites" mentions: "Note: This method does not support Sites.Selected
application permissions." Thus, it is our understanding that site limitations using "Sites.Selected" are not possible with "Search for sites."

Question:

We would like to know the necessary APIs to implement site limitations using "Sites.Selected." Please provide the following information:

  • An alternative method for retrieving a list of sites to replace the "Search for sites" (Graph API). Additionally, please explain the authentication method required to use the API. (Should we use the SharePoint REST API instead of the Graph API?)
  • The method/steps for applying site limitations. If there are multiple ways to do this, such as via API or web management interface, please describe all methods.
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,241 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.
3,031 questions
{count} votes

Accepted answer
  1. Emily Du-MSFT 47,296 Reputation points Microsoft Vendor
    2024-10-04T06:30:40.1766667+00:00

    Instead of Graph API, you could use REST API to search sites in the SharePoint online.

    First, grant users with add-in only / app-only permissions in the SharePoint online. Then use search REST API to search sites.

    Use following endpoint to retrieve a list of sites: https://{your-tenant-name}.sharepoint.com/_api/search/query?querytext='contentclass:STS_Site'&selectproperties='Title,Path'&startrow=0&rowlimit=500.

    This endpoint will return a list of up to 500 SharePoint sites, including the site title and URL. If you need to retrieve more than 500 sites, you can use the startrow parameter to retrieve the next set of sites. For example, to retrieve sites 501-1000, set startrow to 500 and rowlimit to 500.

    References:

    How to grant add-in only / app-only permissions in the SharePoint Online

    Search REST API

    Other ways to search sites in the SharePoint online.

    1.Use UI to search.

    https://learn.microsoft.com/en-us/sharepoint/get-started-with-modern-search-experience

    https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference

    2.Use PowerShell to search.

    https://www.sharepointdiary.com/2018/02/powershell-to-search-sharepoint-export-results-using-keyword-query.html

    3.Use Graph API with Delegation permission to search.

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.