Daniel Haughton
Daniel Haughton

Reputation: 1215

Microsoft Graph API: Access a drive that is not in the "root drive"

I have a SharePoint site where there is a drive that is not the default drive (Shared Documents). How do I access this drive?

Normally to access a file that would be mysite.com/Shared Documents/folder, I would do the following get the site id:

GET /v1.0/sites/{sharepoint.mycompany.com}:/sites/{mySite}:/

I could then retrieve the default drive using:

GET /v1.0/sites/{mySiteId}/drive

In this case, my fail is not in the default drive. How do I access a different drive?

Upvotes: 1

Views: 750

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33094

You need to address the /drives collection rather than the default /drive. You can retrieve the list of Drives that belong to a site by calling:

GET /v1.0/sites/{siteId}/drives?select=id,name

This will return a collection of drive resources:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
    "value": [
        {
            "id": "id1",
            "name": "Documents"
        },
        {
            "id": "id2",
            "name": "Other Documents"
        }

    ]
}

You can then address the drive by id like this:

GET /v1.0/sites/{siteId}/drives/{driveId}

Upvotes: 1

Related Questions