列出 childFolder
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
获取指定文件夹下的文件夹集合。你可以使用 .../me/mailFolders 快捷方式获取顶级文件夹集合并导航到其他文件夹。
默认情况下,此操作不会返回隐藏文件夹。 使用查询参数 includeHiddenFolders ,将它们包括在答复中。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Mail.ReadBasic、Mail.Read、Mail.ReadWrite
委派(个人 Microsoft 帐户)
Mail.ReadBasic、Mail.Read、Mail.ReadWrite
应用程序
Mail.ReadBasic.All、Mail.Read、Mail.ReadWrite
HTTP 请求
若要获取指定文件夹的所有子文件夹(隐藏文件夹除外),请执行以下操作:
GET /me/mailFolders/{id}/childFolders
GET /users/{id | userPrincipalName}/mailFolders/{id}/childFolders
若要在答复中包括 隐藏的 子文件夹,请执行以下操作:
GET /me/mailFolders/{id}/childFolders?includeHiddenFolders=true
GET /users/{id | userPrincipalName}/mailFolders/{id}/childFolders?includeHiddenFolders=true
可选的查询参数
若要返回所有 childFolder 的列表(包括隐藏的项目,其 isHidden 属性为 true),则如 HTTP 请求 部分所示,在请求 URL 中,将 includeHiddenFolders 查询参数指定为 true。
此方法支持 OData 查询参数 来帮助自定义响应。
名称
类型
说明
Authorization
string
Bearer {token}。必需。
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在响应正文中返回 200 OK 响应代码和 mailFolder 对象集合。
示例
示例 1:列出邮件文件夹
请求
下面展示了示例请求。
GET https://graph.microsoft.com/beta/me/mailFolders/AAMkAGVmMDEzM/childFolders
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var childFolders = await graphClient.Me.MailFolders["{mailFolder-id}"].ChildFolders
.Request()
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let childFolders = await client.api('/me/mailFolders/AAMkAGVmMDEzM/childFolders')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/mailFolders/AAMkAGVmMDEzM/childFolders"]]];
[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];
MSGraphMailFolder *mailFolder = [[MSGraphMailFolder alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
MailFolderCollectionPage childFolders = graphClient.me().mailFolders("AAMkAGVmMDEzM").childFolders()
.buildRequest()
.get();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
mailFolderId := "mailFolder-id"
result, err := graphClient.Me().MailFoldersById(&mailFolderId).ChildFolders().Get()
Import-Module Microsoft.Graph.Mail
# A UPN can also be used as -UserId.
Get-MgUserMailFolderChildFolder -UserId $userId -MailFolderId $mailFolderId
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "AAMkAGVmMDEzA",
"displayName": "Internal Screens",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 0,
"unreadItemCount": 2,
"totalItemCount": 2,
"wellKnownName": null,
"isHidden": false
},
{
"id": "AAMkAGVmMDEzB",
"displayName": "Project Falcon",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 0,
"unreadItemCount": 5,
"totalItemCount": 5,
"wellKnownName": null,
"isHidden": false
},
{
"id": "AAMkAGVmMDEzMA",
"displayName": "Finder",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 4,
"unreadItemCount": 0,
"totalItemCount": 0,
"wellKnownName": "searchfolders",
"isHidden": false
}
]
}
示例 2:列出邮件搜索文件夹
请求
下面展示了示例请求。
GET https://graph.microsoft.com/beta/me/mailFolders/searchfolders/childFolders
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var childFolders = await graphClient.Me.MailFolders["{mailFolder-id}"].ChildFolders
.Request()
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let childFolders = await client.api('/me/mailFolders/searchfolders/childFolders')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/mailFolders/searchfolders/childFolders"]]];
[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];
MSGraphMailFolder *mailFolder = [[MSGraphMailFolder alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
MailFolderCollectionPage childFolders = graphClient.me().mailFolders("searchfolders").childFolders()
.buildRequest()
.get();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
mailFolderId := "mailFolder-id"
result, err := graphClient.Me().MailFoldersById(&mailFolderId).ChildFolders().Get()
Import-Module Microsoft.Graph.Mail
# A UPN can also be used as -UserId.
Get-MgUserMailFolderChildFolder -UserId $userId -MailFolderId $mailFolderId
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.mailSearchFolder",
"id": "AAMkAGE1NWMz",
"displayName": "Get MyAnalytics",
"parentFolderId": "AAMkAGE1NWMx",
"childFolderCount": 0,
"unreadItemCount": 6,
"totalItemCount": 6,
"isHidden": false,
"wellKnownName": null,
"isSupported": true,
"filterQuery": "contains(subject, 'MyAnalytics')"
},
{
"@odata.type": "#microsoft.graph.mailSearchFolder",
"id": "AAMkAGE1NWMy",
"displayName": "Action Required",
"parentFolderId": "AAMkAGE1NWMx",
"childFolderCount": 0,
"unreadItemCount": 2,
"totalItemCount": 4,
"isHidden": false,
"wellKnownName": null,
"isSupported": true,
"filterQuery": "contains(subject, 'ACTION REQUIRED')"
}
]
}
示例 3:在指定的邮件文件夹下包含隐藏的子文件夹
下一个示例使用 includeHiddenFolders 查询参数获取特定邮件文件夹中的子文件夹列表(包括隐藏的邮件文件夹)。 答复包含 isHidden 设置为 true 的“待筛选邮件”文件夹。
请求
下面展示了示例请求。
GET https://graph.microsoft.com/beta/me/mailFolders/AAMkAGVmMDEzM/childFolders?includeHiddenFolders=true
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("includeHiddenFolders", "true")
};
var childFolders = await graphClient.Me.MailFolders["{mailFolder-id}"].ChildFolders
.Request( queryOptions )
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let childFolders = await client.api('/me/mailFolders/AAMkAGVmMDEzM/childFolders?includeHiddenFolders=true')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/mailFolders/AAMkAGVmMDEzM/childFolders?includeHiddenFolders=true"]]];
[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];
MSGraphMailFolder *mailFolder = [[MSGraphMailFolder alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new QueryOption("includeHiddenFolders", "true"));
MailFolderCollectionPage childFolders = graphClient.me().mailFolders("AAMkAGVmMDEzM").childFolders()
.buildRequest( requestOptions )
.get();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.ChildFoldersRequestBuilderGetQueryParameters{
IncludeHiddenFolders: true,
}
options := &msgraphsdk.ChildFoldersRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
mailFolderId := "mailFolder-id"
result, err := graphClient.Me().MailFoldersById(&mailFolderId).ChildFolders().GetWithRequestConfigurationAndResponseHandler(options, nil)
Import-Module Microsoft.Graph.Mail
# A UPN can also be used as -UserId.
Get-MgUserMailFolderChildFolder -UserId $userId -MailFolderId $mailFolderId -Includehiddenfolders true
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "AAMkAGVmMDEzA",
"displayName": "Internal Screens",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 0,
"unreadItemCount": 2,
"totalItemCount": 2,
"wellKnownName": null,
"isHidden": false
},
{
"id": "AAMkAGVmMDEzB",
"displayName": "Clutters",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 0,
"unreadItemCount": 5,
"totalItemCount": 5,
"wellKnownName": null,
"isHidden": true
},
{
"id": "AAMkAGVmMDEzMA",
"displayName": "Finder",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 4,
"unreadItemCount": 0,
"totalItemCount": 0,
"wellKnownName": "searchfolders",
"isHidden": false
}
]
}