Muokkaa

Jaa


Get drive

Namespace: microsoft.graph

Important

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Retrieve the properties and relationships of a drive resource.

A drive is the top-level container for a file system, such as OneDrive or SharePoint document libraries.

This API is available in the following national cloud deployments.

Global service US Government L4 US Government L5 (DOD) China operated by 21Vianet

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) Files.Read Files.Read.All, Files.ReadWrite, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All, User.Read
Delegated (personal Microsoft account) Files.Read Files.Read.All, Files.ReadWrite, Files.ReadWrite.All
Application Not supported. Not supported.

HTTP request

Get the current OneDrive of a user

The signed-in user's drive (when using delegated authentication) can be accessed from the me singleton.

If a user has a license for OneDrive but their OneDrive isn't set up yet, this request automatically provisions the user's drive, when using delegated authentication.

GET /me/drive

Get the OneDrive of a user

To access a user's OneDrive or OneDrive for Business, your app must request the drive relationship on the User resource.

If a user has a license for OneDrive but their OneDrive isn't set up yet, this request automatically provisions the user's drive, when using delegated authentication.

GET /users/{idOrUserPrincipalName}/drive

Path parameters

Parameter name Value Description
idOrUserPrincipalName string Required. The identifier for the user object who owns the OneDrive.

Get the document library associated with a group

To access a Group's default document library, your app requests the drive relationship on the Group.

GET /groups/{groupId}/drive

Path parameters

Parameter name Value Description
groupId string Required. The identifier for the group that owns the document library.

Get the document library for a site

To access a Site's default document library, your app requests the drive relationship on the Site.

GET /sites/{siteId}/drive

Path parameters

Parameter name Value Description
siteId string Required. The identifier for the site that contains the document library.

Get a drive by ID

If you have the unique identifier for a drive, you can access it directly from the top-level drives collection.

GET /drives/{driveId}

Path parameters

Parameter name Value Description
driveId string Required. The identifier for the drive requested.

Optional query parameters

These methods support the $select query parameter to shape the response.

Response

Each of these methods returns a Drive resource for the matching drive in the response body.

Error response codes

If the drive doesn't exist and can't be provisioned automatically (when using delegated authentication) an HTTP 404 response is returned.

Examples

Request

The following example shows a request.

GET /me/drive

Response

The following example shows the response.

HTTP/1.1 200 OK
Content-type: application/json

{
    "id": "b!t18F8ybsHUq1z3LTz8xvZqP8zaSWjkFNhsME-Fepo75dTf9vQKfeRblBZjoSQrd7",
    "driveType": "business",
    "owner": {
        "user": {
            "id": "efee1b77-fb3b-4f65-99d6-274c11914d12",
            "displayName": "Ryan Gregg"
        }
    },
    "quota": {
        "deleted": 256938,
        "remaining": 1099447353539,
        "state": "normal",
        "total": 1099511627776
    }
}