将项目添加到捆绑包
命名空间:microsoft.graph
将驱动器中的其他 driveItem 添加到 [捆绑包][]。
Permissions
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
不支持。 |
| 委派(个人 Microsoft 帐户) |
Files.ReadWrite、Files.ReadWrite.All |
| 应用程序 |
不支持。 |
HTTP 请求
POST /drive/bundles/{bundle-id}/children
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供 driveItem 对象的 JSON 表示形式。
响应
如果成功,此方法返回 204 No Content 响应代码。
有关错误响应的信息,请参阅 Microsoft Graph错误响应和资源类型。
示例
请求
下面是将现有项目添加到指定捆绑包的请求示例。
POST https://graph.microsoft.com/v1.0/drive/bundles/{bundle-id}/children
Content-Type: application/json
{
"id": "123456!87"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var driveItem = new DriveItem
{
Id = "123456!87"
};
await graphClient.Drive.Bundles["{driveItem-id}"].Children
.Request()
.AddAsync(driveItem);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const driveItem = {
id: '123456!87'
};
await client.api('/drive/bundles/{bundle-id}/children')
.post(driveItem);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/drive/bundles/{bundle-id}/children"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphDriveItem *driveItem = [[MSGraphDriveItem alloc] init];
[driveItem setId:@"123456!87"];
NSError *error;
NSData *driveItemData = [driveItem getSerializedDataWithError:&error];
[urlRequest setHTTPBody:driveItemData];
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();
DriveItem driveItem = new DriveItem();
driveItem.id = "123456!87";
graphClient.drive().bundles("{bundle-id}").children()
.buildRequest()
.post(driveItem);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
下面展示了示例响应。
HTTP/1.1 204 No Content