driveItem: restore
[アーティクル]
09/13/2021
2 人の共同作成者
この記事の内容
名前空間: microsoft.graph
削除済 みで 、現在ごみ箱に入っている driveItem を復元します。 注 : この機能は現在、個人用のユーザー OneDriveです。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可 」を参照してください。
アクセス許可の種類
アクセス許可 (特権の小さいものから大きいものへ)
委任 (職場または学校のアカウント)
サポートされていません。
委任 (個人用 Microsoft アカウント)
Files.ReadWrite.All
アプリケーション
Files.ReadWrite.All
HTTP 要求
POST /me/drive/items/{item-id}/restore
名前
説明
Authorization
ベアラー {トークン}。必須。
要求本文
要求本文で、次のパラメーターを含む 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"
}