driveItem: restore
本文内容
命名空间:microsoft.graph
还原已删除且当前位于回收站中的driveItem。 注意 :此功能当前仅适用于个人OneDrive。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
不支持。
委派(个人 Microsoft 帐户)
Files.ReadWrite.All
应用程序
Files.ReadWrite.All
HTTP 请求
POST /me/drive/items/{item-id}/restore
名称
说明
Authorization
Bearer {token}。必需。
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
参数
类型
说明
parentReference
ItemReference
可选。 对已删除项目将还原到的父项的引用。
name
String
可选。 已还原项目的新名称。 如果未提供新名称,将同一名称用作原始名称。
响应
如果成功,此方法在响应 200 OK 正文中返回 响应代码和已还原的 driveItem 对象。
示例
以下示例演示如何调用此 API。
请求
下面展示了示例请求。
POST https://graph.microsoft.com/beta/me/drive/items/{item-id}/restore
Content-type: application/json
{
"parentReference": {
"id": "String",
},
"name": "String"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var parentReference = new ItemReference
{
Id = "String"
};
var name = "String";
await graphClient.Me.Drive.Items["{driveItem-id}"]
.Restore(parentReference,name)
.Request()
.PostAsync();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
const driveItem = {
parentReference: {
id: 'String',
},
name: 'String'
};
await client.api('/me/drive/items/{item-id}/restore')
.version('beta')
.post(driveItem);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
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}/restore"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
MSGraphItemReference *parentReference = [[MSGraphItemReference alloc] init];
[parentReference setId:@"String"];
payloadDictionary[@"parentReference"] = parentReference;
NSString *name = @"String";
payloadDictionary[@"name"] = name;
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];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
ItemReference parentReference = new ItemReference();
parentReference.id = "String";
String name = "String";
graphClient.me().drive().items("{item-id}")
.restore(DriveItemRestoreParameterSet
.newBuilder()
.withParentReference(parentReference)
.withName(name)
.build())
.buildRequest()
.post();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "1312abc!1231",
"name": "new-restored-item-name.txt",
"size": 19121,
"lastModifiedDateTime": "2017-12-12T10:40:59Z"
}