Redigera

Dela via


Delete a sharing permission from a file or folder

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.

Remove access to a DriveItem.

Only sharing permissions that are not inherited can be deleted. The inheritedFrom property must be null.

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

HTTP request

DELETE /drives/{drive-id}/items/{item-id}/permissions/{perm-id}
DELETE /groups/{group-id}/drive/items/{item-id}/permissions/{perm-id}
DELETE /me/drive/items/{item-id}/permissions/{perm-id}
DELETE /sites/{site-id}/drive/items/{item-id}/permissions/{perm-id}
DELETE /users/{user-id}/drive/items/{item-id}/permissions/{perm-id}

Optional request headers

Name Type Description
if-match string If this request header is included and the eTag (or cTag) provided does not match the current tag on the item, a 412 Precondition Failed response is returned and the item will not be deleted.

Response

If successful, this method returns 204 No Content response code.

Example

This example removes the permission identified as {perm-id} from the item {item-id} in the current user's OneDrive.

DELETE https://graph.microsoft.com/beta/me/drive/items/{item-id}/permissions/{perm-id}

Response

HTTP/1.1 204 No Content

Remarks

  • Drives with a driveType of personal (OneDrive Personal) cannot create or modify permissions on the root DriveItem.