List available drives
Article
08/04/2022
5 minutes to read
9 contributors
Feedback
In this article
Namespace: microsoft.graph
Retrieve the list of Drive resources available for a target User, Group, or Site .
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Files.Read, Files.ReadWrite, Files.Read.All, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All
Delegated (personal Microsoft account)
Files.Read, Files.ReadWrite, Files.Read.All, Files.ReadWrite.All
Application
Files.Read.All, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All
List a group's drives
To list the document libraries for a group, your app requests the drives relationship on the Group.
HTTP request
GET https://graph.microsoft.com/v1.0/groups/02bd9fd6-8f93-4758-87c3-1fb73740a315/drives
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var drives = await graphClient.Groups["{group-id}"].Drives
.Request()
.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
let drives = await client.api('/groups/02bd9fd6-8f93-4758-87c3-1fb73740a315/drives')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DriveCollectionPage drives = graphClient.groups("02bd9fd6-8f93-4758-87c3-1fb73740a315").drives()
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.GroupsById("group-id").Drives().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestResult = $graphServiceClient->groupsById('group-id')->drives()->get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
List a site's drives
To list the document libraries for a site, your app requests the drives relationship on the Site.
GET /sites/{siteId}/drives
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var drives = await graphClient.Sites["{site-id}"].Drives
.Request()
.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
let drives = await client.api('/sites/{siteId}/drives')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DriveCollectionPage drives = graphClient.sites("{siteId}").drives()
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.SitesById("site-id").Drives().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestResult = $graphServiceClient->sitesById('site-id')->drives()->get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
List a user's drives
GET https://graph.microsoft.com/v1.0/users/48d31887-5fad-4d73-a9f5-3c356e68a038/drives
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var drives = await graphClient.Users["{user-id}"].Drives
.Request()
.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
let drives = await client.api('/users/48d31887-5fad-4d73-a9f5-3c356e68a038/drives')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DriveCollectionPage drives = graphClient.users("48d31887-5fad-4d73-a9f5-3c356e68a038").drives()
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.UsersById("user-id").Drives().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestResult = $graphServiceClient->usersById('user-id')->drives()->get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
List the current user's drives
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var drives = await graphClient.Me.Drives
.Request()
.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DriveCollectionPage drives = graphClient.me().drives()
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.Me().Drives().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestResult = $graphServiceClient->me()->drives()->get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Optional query parameters
This method supports the $expand
, $select
, $skipToken
, $top
, and $orderby
OData query parameters to customize the response.
Response
If successful, this method returns a 200 OK
response code and collection of Drive objects in the response body.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
"value": [
{
"createdDateTime": "2017-07-27T02:41:36Z",
"description": "",
"id": "b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd",
"lastModifiedDateTime": "2018-03-27T07:34:38Z",
"name": "OneDrive",
"webUrl": "https://m365x214355-my.sharepoint.com/personal/meganb_m365x214355_onmicrosoft_com/Documents",
"driveType": "business",
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"lastModifiedBy": {
"user": {
"email": "MeganB@M365x214355.onmicrosoft.com",
"id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
"displayName": "Megan Bowen"
}
},
"owner": {
"user": {
"email": "MeganB@M365x214355.onmicrosoft.com",
"id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
"displayName": "Megan Bowen"
}
},
"quota": {
"deleted": 0,
"remaining": 1099217021300,
"state": "normal",
"total": 1099511627776,
"used": 294606476
}
}
]
}
Most users will only have a single Drive resource.
Groups and Sites may have multiple Drive resources available.
Drives with the system facet are hidden by default.
To list them, include system
in your $select
statement.