How to list all SharePoint sites with graph api

Kaustubh Nangare 30 Reputation points
2024-08-12T16:00:15.7933333+00:00

Hi,

I am seeing change in behaviour using site search query while listing all SharePoint sites for user.

Using https://graph.microsoft.com/v1.0/sites?search=* returns less sites as compared to https://graph.microsoft.com/v1.0/sites?search=. I am using Sites.Read.All delegated permission to list sites.

From answer that I found on support question, recommends using ?search=* but that does not return few sites that user has access to.

Any input on this is appreciated.

Microsoft 365 and Office SharePoint Development
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Rohit Raghuwanshi - MSFT 625 Reputation points Microsoft External Staff
    2024-08-12T22:47:21.3166667+00:00

    Hello Kaustubh Nangare,

    I successfully retrieved all SharePoint sites using the endpoint "https://graph.microsoft.com/v1.0/sites" with the Application permission Sites.Read.All. The delegated permission is not supported for this request, as noted in the documentation provided.
    https://learn.microsoft.com/en-us/graph/api/site-get?view=graph-rest-1.0&tabs=http#permissions

    1. Using Application permission to list Sites

    User's image

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


1 additional answer

Sort by: Most helpful
  1. Kaustubh Nangare 30 Reputation points
    2024-08-20T08:02:51.4966667+00:00

    There was an intermittent issue with api behaviour, which seems to have fixed now.
    Returns all sites when using https://graph.microsoft.com/v1.0/sites?search=*

    0 comments No comments

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.