Why does https://graph.microsoft.com/v1.0/sites need a blank search parameter to return a list of sites?

Taylor Reece 0 Reputation points
2023-01-27T14:55:48.59+00:00

According to docs, you should be able to make a request to https://graph.microsoft.com/v1.0/sites and get a list of your Sharepoint sites back. Both in the Graph API explorer and with my own HTTP requests, this seems to always return an empty list.

image

However, if I add a blank search parameter (i.e. make a request to https://graph.microsoft.com/v1.0/sites?search=), I do get all of my sites back.

image

Is that a bug or a feature? Do you need to include an empty search parameter for other endpoints in the Graph API?

Thanks! Taylor

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,791 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,793 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 96,436 Reputation points MVP
    2023-01-27T15:40:33.1966667+00:00

    Well, according to the documentation, only application permissions are supported for that query, so it shouldn't even work in the Graph explorer. Not sure if bug, improperly documented feature or anything else, but I will ping few people as it's interesting to know the answer here :)

    0 comments No comments

  2. RaytheonXie_MSFT 32,081 Reputation points Microsoft Vendor
    2023-01-30T01:58:19.8833333+00:00

    Hi @Taylor Reece

    Per my research, https://graph.microsoft.com/v1.0/sites only support Application permission. So we are unable to call GET /sites in the graph explorer tool.

    User's image

    And in the search for sites document, this is a different endpoint with GET /sites. The endpoint support Delegated (work or school account). So we will get result in the graph explorer tool while GET /sites returns empty.

    User's image


    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.