permission: revokeGrants
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
通过从链接中删除指定收件人,撤销对通过共享链接授予的listItem 或 []的访问权限。
注意: 此功能仅适用于共享范围为用户的链接。
Permissions
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Files.ReadWrite、Files.ReadWrite.All、Sites.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持
应用程序
Files.ReadWrite.All、Sites.ReadWrite.All
HTTP 请求
POST /drives/{drive-id}/items/{item-id}/permissions/{perm-id}/revokeGrants
POST /groups/{group-id}/drive/items/{item-id}/permissions/{perm-id}/revokeGrants
POST /me/drive/items/{item-id}/permissions/{perm-id}/revokeGrants
POST /sites/{site-id}/drive/items/{item-id}/permissions/{perm-id}/revokeGrants
POST /sites/{site-id}/lists/{list-id}/items/{listItem-id}/driveItem/permissions/{perm-id}/revokeGrants
POST /users/{user-id}/drive/items/{item-id}/permissions/{perm-id}/revokeGrants
名称
说明
Authorization
Bearer {token}。必需。
Content-Type
application/json. Required.
请求正文
在请求正文中,提供参数的 JSON 表示形式。
下表显示了可用于此操作的参数。
响应
如果成功,此操作在响应 200 OK 正文中返回 响应 代码和权限。
示例
请求
POST /me/drive/items/{item-id}/permissions/{perm-id}/revokeGrants
Content-Type: application/json
{
"grantees": [
{
"email": "ryan@contoso.com"
}
]
}
const options = {
authProvider,
};
const client = Client.init(options);
const permission = {
grantees: [
{
email: 'ryan@contoso.com'
}
]
};
await client.api('/me/drive/items/{item-id}/permissions/{perm-id}/revokeGrants')
.version('beta')
.post(permission);
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var grantees = new List<DriveRecipient>()
{
new DriveRecipient
{
Email = "ryan@contoso.com"
}
};
await graphClient.Me.Drive.Items["{driveItem-id}"].Permissions["{permission-id}"]
.RevokeGrants(grantees)
.Request()
.PostAsync();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/drive/items/{item-id}/permissions/{perm-id}/revokeGrants"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSMutableArray *granteesList = [[NSMutableArray alloc] init];
MSGraphDriveRecipient *grantees = [[MSGraphDriveRecipient alloc] init];
[grantees setEmail:@"ryan@contoso.com"];
[granteesList addObject: grantees];
payloadDictionary[@"grantees"] = granteesList;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<DriveRecipient> granteesList = new LinkedList<DriveRecipient>();
DriveRecipient grantees = new DriveRecipient();
grantees.email = "ryan@contoso.com";
granteesList.add(grantees);
graphClient.me().drive().items("{item-id}").permissions("{perm-id}")
.revokeGrants(PermissionRevokeGrantsParameterSet
.newBuilder()
.withGrantees(granteesList)
.build())
.buildRequest()
.post();
响应
如果成功,此方法在响应正文中返回 Permission 资源,该资源表示共享链接的更新状态。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "123ABC",
"roles": ["write"],
"link": {
"type": "edit",
"scope": "users",
"webUrl": "https://contoso-my.sharepoint.com/personal/ellen_contoso_com/...",
"application": {
"id": "1234",
"displayName": "Sample Application"
},
}
}