Office 365的错误未找到资源为段“MailFolders” [英] Office 365 error Resource not found for the segment 'MailFolders'
问题描述
我创建的功能显示在办公室我的网页的一个365邮件。
目前我使用Microsoft.Office365.Discovery(v1.0.22)和Microsoft.Office365.OutlookServices(v1.0.41.0)的NuGet包。
我需要显示文件夹明智的邮件总数coundand总未读计数,但Microsoft.Office365.OutlookServices(v.1.0.41.0)does'n具有这样的功能。
所以我下载nugetpackage Microsoft.Office365.OutlookServices(v.2.0.1.0),它具有属性UnreadItemCount和TotalItemCount
例如:
VAR folderResult =等待outlookServicesClient.Me.MailFolders.ExecuteAsync();
变种CNT = folderResult.CurrentPage.ToList()[0] .TotalItemCount;
但是当我打电话ExecuteAsync()它提供了以下错误:
{
错误:
{
code:RequestBroker-ParseUri
资源未找到段MailFolders'。:消息
}
}
这有什么错呢?
新增如何使用OutlookServicesClient
DiscoveryClient discClient =新DiscoveryClient(SettingsHelper.DiscoveryServiceEndpointUri,
异步()=>
{
VAR authResult =等待authContext.AcquireTokenSilentAsync(SettingsHelper.DiscoveryServiceResourceId,新ClientCredential(SettingsHelper.ClientId,SettingsHelper.AppKey),新UserIdentifier的(userObjectId,UserIdentifierType.UniqueId)); 返回authResult.AccessToken;
}); VAR DCR =等待discClient.DiscoverCapabilityAsync(capabilityName); 返回新OutlookServicesClient(dcr.ServiceEndpointUri,
异步()=>
{
VAR authResult =等待authContext.AcquireTokenSilentAsync(dcr.ServiceResourceId,新ClientCredential(SettingsHelper.ClientId,SettingsHelper.AppKey),新UserIdentifier的(userObjectId,UserIdentifierType.UniqueId)); 返回authResult.AccessToken;
});
和用于网址
私有静态字符串_discoverySvcResourceId =https://api.office.com/discovery/;
私人静态字符串_discoverySvcEndpointUri =https://api.office.com/discovery/v2.0/me/;
您,如果您使用的是1.0版API端点会得到错误。确保当您创建 OutlookServicesClient
对象,你构造这样说:
OutlookServicesClient客户端=
新OutlookServicesClient(新的URI(https://outlook.office.com/api/v2.0),为gettoken);
I am creating functionality in Asp.net webform to display Office 365 mails in one of my page. Currently I am using Microsoft.Office365.Discovery (v1.0.22) and Microsoft.Office365.OutlookServices (v1.0.41.0) nuget package. I need to display Folder wise total mail coundand total unread count but Microsoft.Office365.OutlookServices (v.1.0.41.0) does'n have such functionality.
So i downloaded nugetpackage Microsoft.Office365.OutlookServices (v.2.0.1.0) which has properties UnreadItemCount and TotalItemCount
ex:
var folderResult = await outlookServicesClient.Me.MailFolders.ExecuteAsync();
var cnt = folderResult.CurrentPage.ToList()[0].TotalItemCount;
but when i call ExecuteAsync() it gives below error:
{
"error":
{
"code":"RequestBroker-ParseUri",
"message":"Resource not found for the segment 'MailFolders'."
}
}
Is there anything wrong with it?
Added How to use OutlookServicesClient
DiscoveryClient discClient = new DiscoveryClient(SettingsHelper.DiscoveryServiceEndpointUri,
async () =>
{
var authResult = await authContext.AcquireTokenSilentAsync(SettingsHelper.DiscoveryServiceResourceId, new ClientCredential(SettingsHelper.ClientId, SettingsHelper.AppKey), new UserIdentifier(userObjectId, UserIdentifierType.UniqueId));
return authResult.AccessToken;
});
var dcr = await discClient.DiscoverCapabilityAsync(capabilityName);
return new OutlookServicesClient(dcr.ServiceEndpointUri,
async () =>
{
var authResult = await authContext.AcquireTokenSilentAsync(dcr.ServiceResourceId, new ClientCredential(SettingsHelper.ClientId, SettingsHelper.AppKey), new UserIdentifier(userObjectId, UserIdentifierType.UniqueId));
return authResult.AccessToken;
});
and URLs that is used
private static string _discoverySvcResourceId = "https://api.office.com/discovery/";
private static string _discoverySvcEndpointUri = "https://api.office.com/discovery/v2.0/me/";
You'll get that error if you are using the v1 API endpoint. Make sure when you create your OutlookServicesClient
object you construct it this way:
OutlookServicesClient client =
new OutlookServicesClient(new Uri("https://outlook.office.com/api/v2.0"), GetToken);
这篇关于Office 365的错误未找到资源为段“MailFolders”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!