how to find site id and drive id for graph API

Anjali Shevadkar 1 Reputation point
2022-02-10T13:47:13.643+00:00

how to find site id and drive id for graph API

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,618 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShivaniRai-MSFT 2,726 Reputation points
    2022-02-10T14:32:45.313+00:00

    Hi @Anjali Shevadkar ,

    According to this document, use the below Graph API Endpoint to fetch the Id of a SharePoint site by passing site name https://graph.microsoft.com/v1.0/sites?search={query}

    Example Reference: Here 'test' is the site name for which we want the site-Id. Grant sites.read.all permission to call this API (please refer below example screenshot from Graph Explorer)
    173186-image.png

    To fetch drive Id, these are the Endpoints you can use:

    GET /groups/{groupId}/drives (To fetch the drives within a group)  
    GET /sites/{siteId}/drives (To fetch drives for a particular site)  
    GET /users/{userId}/drives (To fetch user's drives)  
    GET /me/drives (To list the current user's drive)  
    

    Example reference: To fetch drive Id of a particular site. Grant Files.Read permission for this API(please refer below screenshot from Graph Explorer)
    173120-image.png

    Reference Docs:
    https://learn.microsoft.com/en-us/graph/api/site-search?view=graph-rest-1.0&tabs=http#http-request
    https://learn.microsoft.com/en-us/graph/api/drive-list?view=graph-rest-1.0&tabs=http

    Hope this helps.

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

    2 people found this answer helpful.
    0 comments No comments