How to get all sites with Microsoft Graph API Explorer?

Jack Le 0 Reputation points
2023-12-11T04:55:51.88+00:00

I'm testing the API with the Graph Explorer on https://developer.microsoft.com/en-us/graph/graph-explorer

I logged in with my global admin account, grant the required permissions

User's image

However, when I ran the GET https://graph.microsoft.com/v1.0/sites/getAllSites

I received the 403 response

{
    "error": {
        "code": "accessDenied",
        "message": "Access denied",
        "innerError": {
            "date": "2023-12-11T04:51:03",
            "request-id": "ee30d13f-5558-4803-8b83-7240c7479f7d",
            "client-request-id": "d0fdc3cd-3773-b974-6c26-7d72e0de1ff1"
        }
    }
}

The same thing happened when I use Postman with the same access token. What other permissions do I need to run this query?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,565 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,341 Reputation points
    2023-12-11T06:40:08.8766667+00:00

    Hi @Jack Le

    As of a few months ago, this endpoint still did not support delegated permissions, but I noticed that Microsoft recently removed this description, not sure if it has been fixed now.

    As a solution, you can try running the following API in Graph Explorer, it can help you list all sites.

    https://graph.microsoft.com/v1.0/sites?search=*
    

    Hope this helps.

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


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.