SharePoint: Find Site ID and Drive IDs

To automate tasks like automatic folder creation for new sales customers or integrating SharePoint with other systems, you’ll often need to interact with its resources programmatically. This is typically done using APIs like Microsoft Graph or Power Automate. To get started, you’ll need to identify two crucial pieces of information: the Site ID and the Drive ID.

This guide will show you how to locate these identifiers using two methods:

  1. Using the SharePoint User Interface (UI): A straightforward approach that leverages the built-in tools of SharePoint.
  2. Using Microsoft Graph Explorer: A more technical method that provides deeper insights into the underlying Graph API.

By following these steps, you’ll be well-equipped to harness the power of SharePoint’s APIs and automate your workflows.


 

Locate the Site ID

You can find SharePoints Site ID in two ways.

Simple Way:
  • Place the URL of your SharePoint site within a browser.
  • Add /_api/site/id/ to the end of the URL
    • Example: https://yourcoolsite.sharepoint.com/sites/DaveTest/_api/site/id
  • Note the string after the Edm.Guid.  This is your Site ID.

 

Graph Explorer:
  • Open Microsoft Graph Explorer.
  • Sign in with your Microsoft 365 account.
  • Click Modify Permissions.
  • Search and add the following permissions:
    • Sites.Read.All

  • Use the following endpoint to get the site details:
    GET https://graph.microsoft.com/v1.0/sites/<tenant>.sharepoint.com:/sites/<site-name>
  • Run the query. The response will include the Site ID:
    {
      "id": "<site-id>",
      "name": "<site-name>",
      "webUrl": "https://<tenant>.sharepoint.com/sites/<site-name>",
      ...
    }

    Copy the value of the ID after your SharePoint name


 

Retrieve the Drive ID

The Drive ID corresponds to the document library or folder you want to access. Follow these steps:

 

Using Microsoft Graph Explorer

  1. With the Site ID you found above, use the following endpoint to list drives (document libraries) in the site:

    GET https://graph.microsoft.com/v1.0/sites/mysitename.sharepoint.com,*string from SiteID*/drives
  2. Run the query. The response will list all document libraries along with their Drive IDs:

  1. Identify the library you need and copy its id.

 

For Specific Folders

  1. Use the following endpoint to list the root folder contents of a drive:

    GET https://graph.microsoft.com/v1.0/drives/<drive-id>/root/children
  2. Browse through the results to find your folder and its corresponding ID.


 

Finding the Site ID and Drive ID in SharePoint is essential for seamless integration with APIs or automation tools. By following the steps outlined above, you can confidently locate these identifiers and use them in your workflows or applications. Whether you prefer using Graph Explorer, PowerShell, or SharePoint’s UI, there’s a method suitable for your needs.

Discover more Microsoft 365 tips and tricks in our other blog posts.

I hope you found this helpful!