列出捆绑包
本文内容
命名空间:microsoft.graph
获取用户驱动器 中所有 包的列表。
Permissions
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
不支持。
委派(个人 Microsoft 帐户)
Files.Read、Files.ReadWrite、Files.Read.All、Files.ReadWrite.All
应用程序
不支持。
HTTP 请求
GET /drive/bundles
可选的查询参数
此方法支持使用 $filter OData 查询参数 来帮助自定义响应。
你不能使用查询参数 expand=children 列出捆绑包。
名称
说明
Authorization
Bearer {token}。必需。
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在响应200 OK正文中返回 响应代码和 [bundlebundle] 对象集合。[]
有关错误响应的信息,请参阅 Microsoft Graph错误响应和资源类型 。
示例
示例 1:列出驱动器中所有捆绑包
若要请求枚举驱动器中定义的所有捆绑包,你可以向不带任何参数的 捆绑 包集合提出请求。
请求
请求示例如下所示。
GET https://graph.microsoft.com/beta/drive/bundles
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var bundles = await graphClient.Drive.Bundles
.Request()
.GetAsync();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
let bundles = await client.api('/drive/bundles')
.version('beta')
.get();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/drive/bundles"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphDriveItem *driveItem = [[MSGraphDriveItem alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DriveItemCollectionPage bundles = graphClient.drive().bundles()
.buildRequest()
.get();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.Drive().Bundles().Get()
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "0123456789abc",
"name": "Vacation photo album",
"bundle": {
"childCount": 1,
"album": { }
}
},
{
"id": "0120310201abd",
"name": "Family shared files",
"bundle": {
"childCount": 1
}
}
],
"@odata.nextLink": "https://..."
}
示例 2:列出驱动器中所有的相册
若要筛选从对 bundles filter 集合的请求返回的捆绑包列表,可以使用查询字符串参数通过检查捆绑包上是否存在 Facet 来指定要返回的捆绑包的类型。
请求
请求示例如下所示。
GET https://graph.microsoft.com/v1.0/drive/bundles?filter=bundle/album%20ne%20null
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("filter", "bundle/album ne null")
};
var bundles = await graphClient.Drive.Bundles
.Request( queryOptions )
.Filter("bundle/album ne null")
.GetAsync();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
let bundles = await client.api('/drive/bundles?filter=bundle/album%20ne%20null')
.filter('bundle/album ne null')
.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?filter=bundle/album%20ne%20null"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphDriveItem *driveItem = [[MSGraphDriveItem alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new QueryOption("filter", "bundle/album ne null"));
DriveItemCollectionPage bundles = graphClient.drive().bundles()
.buildRequest( requestOptions )
.filter("bundle/album ne null")
.get();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.BundlesRequestBuilderGetQueryParameters{
Filter: "bundle/album%20ne%20null",
}
options := &msgraphsdk.BundlesRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
result, err := graphClient.Drive().Bundles().GetWithRequestConfigurationAndResponseHandler(options, nil)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
下面展示了示例响应。 对捆绑包终结点的 GET 响应是包含 [捆绑包的 driveItem][] 资源的 [数组][]。
因为所有捆绑包都是项目,所以你可以对它们使用所有标准项操作。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "0123456789abc",
"name": "Vacation photo album",
"bundle": {
"childCount": 1,
"album": { }
}
},
{
"id": "120301010abcd",
"name": "Seattle Center event",
"bundle": {
"childCount": 4,
"album": { }
},
"tags": [
{
"name": "outside",
"autoTagged": { }
}
]
}
]
}