[英]how to solve "Microsoft.graph.serviceexception code generalexceptionmessage an error occurred sending the request" while fetching calendar events?
I have created an auth provider using user-password auth provider but and trying to retrieve calendar events in bot code which is in c#, having bot framework 4我已经使用用户密码身份验证提供程序创建了一个身份验证提供程序,但并尝试在机器人代码中检索日历事件,该代码位于 c#,具有机器人框架 4
IPublicClientApplication publicClientApplication =
PublicClientApplicationBuilder
.Create("jhnjchdjvd")
.WithTenantId("sdfdf")
.Build();
var s = new SecureString();
s.AppendChar('<');
s.AppendChar('T');
s.AppendChar('N');
s.AppendChar('>');
s.AppendChar('7');
UsernamePasswordProvider authProvider = new UsernamePasswordProvider(publicClientApplication, scopes);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
Microsoft.Graph.User me = await graphClient.Me.Request()
.WithUsernamePassword("kjkhv@indica.onmicrosoft.com",
s).GetAsync();
var events = await graphClient.Me.Events
.Request()
.Header("Prefer", "outlook.timezone=\"Pacific Standard Time\"")
.Select(e => new
{
e.Subject,
e.Body,
e.BodyPreview,
e.Organizer,
e.Attendees,
e.Start,
e.End,
e.Location
})
.GetAsync();
Above code throws exception which is上面的代码抛出异常是
Microsoft.graph.serviceexception code generalexceptionmessage an error occurred sending the request Microsoft.graph.serviceexception 代码 generalexceptionmessage 发送请求时发生错误
How can I solve this error?我该如何解决这个错误?
"Install-Package Microsoft.Identity.Client -Pre". “安装包 Microsoft.Identity.Client -Pre”。 This command installs latest MSAL library.此命令安装最新的 MSAL 库。
The same issue in my case was caused by revoking the Task
function by .GetAwaiter().GetResult()
.在我的案例中,同样的问题是由.GetAwaiter().GetResult()
撤销Task
function 引起的。
Solution: I replaced the .GetAwaiter().GetResult()
with await
approach.解决方案:我用await
方法替换了.GetAwaiter().GetResult()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.