获取捆绑包
本文内容
命名空间:microsoft.graph
根据捆绑 [包的唯一][] ID 检索捆绑包的元数据。
Permissions
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
不支持。
委派(个人 Microsoft 帐户)
Files.Read、Files.ReadWrite、Files.Read.All、Files.ReadWrite.All
应用程序
不支持。
HTTP 请求
GET /drive/bundles/{bundle-id}
GET /drive/items/{bundle-id}
由于捆绑包是项,因此可以使用 items 集合返回有关捆绑包的元数据。
为了方便起见,您还可以使用 bundles 集合来确保在响应中获取捆绑包。
可选的查询参数
此方法支持使用 OData 查询参数 来帮助自定义响应。
名称
说明
Authorization
Bearer {token}。必需。
if-none-match
eTag。 可选。 如果包含此请求标头,并且提供的 eTag (或 cTag) 与文件上的当前标记匹配,则返回 304 Not Modified 响应。
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在响应200 OK正文中返回 响应代码和 driveItem object that contains the [bundle][bundle]。
有关错误响应的信息,请参阅 Microsoft Graph错误响应和资源类型 。
示例
示例 1:获取捆绑包
请求
请求示例如下所示。
GET https://graph.microsoft.com/v1.0/drive/bundles/{bundle-id}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var driveItem = await graphClient.Drive.Bundles["{driveItem-id}"]
.Request()
.GetAsync();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
let driveItem = await client.api('/drive/bundles/{bundle-id}')
.get();
有关如何将 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}"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphDriveItem *driveItem = [[MSGraphDriveItem alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DriveItem driveItem = graphClient.drive().bundles("{bundle-id}")
.buildRequest()
.get();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
driveItemId := "driveItem-id"
result, err := graphClient.Drive().BundlesById(&driveItemId).Get()
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "0123456789abc",
"name": "My Photo Album Bundle",
"eTag": "etag",
"cTag": "etag",
"createdBy": { "user": { "id": "1234", "displayName": "Ryan Gregg" } },
"createdDateTime": "datetime",
"lastModifiedBy": { "user": { "id": "1234", "displayName": "Ryan Gregg" } },
"lastModifiedDateTime": "datetime",
"size": 1234,
"webUrl": "http://onedrive.com/...",
"bundle": {
"childCount": 4,
"album": { }
}
}
示例 2:在单个调用中获取捆绑包及其子项
expand使用查询字符串参数 将捆绑包的子项包括在检索捆绑包元数据的同一请求中。
请求
请求示例如下所示。
GET https://graph.microsoft.com/v1.0/drive/items/{bundle-id}?expand=children
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("expand", "children")
};
var driveItem = await graphClient.Drive.Items["{driveItem-id}"]
.Request( queryOptions )
.GetAsync();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
let driveItem = await client.api('/drive/items/{bundle-id}?expand=children')
.get();
有关如何将 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/items/{bundle-id}?expand=children"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphDriveItem *driveItem = [[MSGraphDriveItem alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new QueryOption("expand", "children"));
DriveItem driveItem = graphClient.drive().items("{bundle-id}")
.buildRequest( requestOptions )
.get();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.DriveItemRequestBuilderGetQueryParameters{
Expand: "children",
}
options := &msgraphsdk.DriveItemRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
driveItemId := "driveItem-id"
result, err := graphClient.Drive().ItemsById(&driveItemId).GetWithRequestConfigurationAndResponseHandler(options, nil)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
下面展示了示例响应。 此调用将返回捆绑包元数据和捆绑包的子项列表。
如果捆绑包没有子项,它将返回空集合。
如果捆绑包中的子项数量大于默认页面大小, children@odata.nextLink 属性将返回一个 URL,该 URL 可用于请求捆绑包中的下一页子项。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "101230100alkc",
"name": "My Cool Day at the Beach",
"children": [
{ "id": "120100abab", "name": "image1.jpg", "file": {} },
{ "id": "120100abo1", "name": "image2.jpg", "file": {} }
],
"children@odata.nextLink": "https://api.onedrive.com/v1.0/..."
}