名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
driveItem を新しい親に移動します。
driveItem を新しい親アイテムに移動するには、移動する driveItem の parentReference に対する更新がアプリによって要求されます。 移動は特別な種類の 更新 操作です。
アプリでは、新しいコンテナーへのアイテムの移動と、アイテムの別のプロパティの更新を単一の要求に組み合わせることができます。
driveItem が同じサイトまたはコンテナー内で移動された場合、既存のすべての共有リンクは引き続き機能します。
driveItem が別のサイトまたはコンテナーに移動された場合、既存の共有リンクは機能しなくなります。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
Files.ReadWrite |
Files.ReadWrite.All、Sites.ReadWrite.All |
| 委任 (個人用 Microsoft アカウント) |
Files.ReadWrite |
Files.ReadWrite.All |
| アプリケーション |
Files.ReadWrite.All |
Sites.ReadWrite.All |
注:
SharePoint Embedded には、コンテナーのコンテンツにアクセスするための FileStorageContainer.Selected アクセス許可が必要です。 このアクセス許可は、前に説明した権限とは異なります。 Microsoft Graph のアクセス許可に加えて、アプリには、この API を呼び出すために必要な コンテナーの種類のアクセス許可 が必要です。 詳細については、「 SharePoint Embedded の認証と承認」を参照してください。
HTTP 要求
PATCH /drives/{drive-id}/items/{item-id}
PATCH /groups/{group-id}/drive/items/{item-id}
PATCH /me/drive/items/{item-id}
PATCH /sites/{site-id}/drive/items/{item-id}
PATCH /users/{user-id}/drive/items/{item-id}
| 名前 |
型 |
説明 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
|
| if-match |
String |
この要求ヘッダーが含まれていて、指定された eTag (または cTag) がフォルダーの現在の eTag と一致しない場合は、 412 Precondition Failed 応答が返されます。 省略可能。 |
要求本文
要求の本文内に、parentReference プロパティの新しい値を指定します。
要求本文に含まれていない既存のプロパティは、以前の値を維持するか、他のプロパティ値の変更に基づいてプロパティが再計算されます。
最適なパフォーマンスを得るには、変更された値のみを含め、変更されていない値を省略します。
注:
項目をドライブのルートに移動する場合、アプリケーションでは、 "id: root" 構文ではなく、ルート フォルダーの実際の ID を親参照として使用する必要があります。
応答
成功した場合、このメソッドは応答コード 200 OK と、更新された driveItem リソースを応答本文に返します。
エラーが返される方法については、「 エラー応答」を参照してください。
例
要求
次の例では、 {item-id} で指定された項目を、ID new-parent-folder-idを使用してユーザーのドライブ内のフォルダーに移動します。
PATCH https://graph.microsoft.com/beta/me/drive/items/{item-id}
Content-type: application/json
{
"parentReference": {
"id": "new-parent-folder-id"
},
"name": "new-item-name.txt"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new DriveItem
{
ParentReference = new ItemReference
{
Id = "new-parent-folder-id",
},
Name = "new-item-name.txt",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDriveItem()
parentReference := graphmodels.NewItemReference()
id := "new-parent-folder-id"
parentReference.SetId(&id)
requestBody.SetParentReference(parentReference)
name := "new-item-name.txt"
requestBody.SetName(&name)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
items, err := graphClient.Drives().ByDriveId("drive-id").Items().ByDriveItemId("driveItem-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DriveItem driveItem = new DriveItem();
ItemReference parentReference = new ItemReference();
parentReference.setId("new-parent-folder-id");
driveItem.setParentReference(parentReference);
driveItem.setName("new-item-name.txt");
DriveItem result = graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").patch(driveItem);
const options = {
authProvider,
};
const client = Client.init(options);
const driveItem = {
parentReference: {
id: 'new-parent-folder-id'
},
name: 'new-item-name.txt'
};
await client.api('/me/drive/items/{item-id}')
.version('beta')
.update(driveItem);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\DriveItem;
use Microsoft\Graph\Beta\Generated\Models\ItemReference;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DriveItem();
$parentReference = new ItemReference();
$parentReference->setId('new-parent-folder-id');
$requestBody->setParentReference($parentReference);
$requestBody->setName('new-item-name.txt');
$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->patch($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Files
$params = @{
parentReference = @{
id = "new-parent-folder-id"
}
name = "new-item-name.txt"
}
Update-MgBetaDriveItem -DriveId $driveId -DriveItemId $driveItemId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.drive_item import DriveItem
from msgraph_beta.generated.models.item_reference import ItemReference
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DriveItem(
parent_reference = ItemReference(
id = "new-parent-folder-id",
),
name = "new-item-name.txt",
)
result = await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').patch(request_body)
応答
次の例は、この移動要求への応答を示しています。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "0123456789abc",
"name": "new-item-name.txt",
"parentReference":
{
"driveId": "11231001",
"path": "/drive/root:/Documents",
"id": "1231203102!1011"
}
}