driveItem: discardCheckout

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.

Discard the check out of a driveItem. This action releases a driveItem resource that was previously checked out. Any changes made to the item while it was checked out are discarded.

The same user that performed the checkout must discard it. Another alternative is to use application permissions.

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.ReadWrite Files.ReadWrite.All, Sites.ReadWrite.All
Delegated (personal Microsoft account) Files.ReadWrite Files.ReadWrite.All
Application Files.ReadWrite.All Sites.ReadWrite.All

Note

SharePoint Embedded requires the FileStorageContainer.Selected permission to access the content of the container. This permission is different from the ones mentioned previously. For more information, see SharePoint Embedded authentication and authorization. In addition to Microsoft Graph permissions, your app must have the necessary container type-level permission or permissions to call this API. For more information, see container types. To learn more about container type-level permissions, see SharePoint Embedded authorization.

HTTP request

POST /drive/root/discardCheckout
POST /drives/{drivesId}/root/discardCheckout
POST /shares/{sharesId}/root/discardCheckout
POST /drive/items/{driveItemId}/discardCheckout
POST /shares/{sharesId}/driveItem/discardCheckout
POST /drive/bundles/{driveItemId}/discardCheckout
POST /drive/special/{driveItemId}/discardCheckout
POST /drive/following/{driveItemId}/discardCheckout

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.

Request body

Don't supply a request body for this method.

Response

If successful, this action returns a 204 No Content response code.

Error responses

The request returns 400 Bad Request if the file isn't checked out. Requests made with delegated access return 423 Locked if another user has the file checked out. Requests made with application access can discard any checkout.

For more information about how errors are returned, see Error responses.

Examples

Request

The following example shows a discard checkout request on a file identified by {item-id}.

POST https://graph.microsoft.com/beta/drives/{drive-id}/items/{item-id}/discardCheckout

Response

The following example shows the response.

HTTP/1.1 204 No content