如何解决状态代码:0 Microsoft.Graph.ServiceException:代码:tooManyRetries 消息:发送请求时遇到超过 3 次重试
当我们尝试使用 Graph API 从日历中获取会议时,我们遇到了异常
获取日历事件的代码:
GraphServiceClient service = new GraphServiceClient(
new DelegateAuthenticationProvider(
async (request) =>
{
request.Headers.Authorization =
new AuthenticationHeaderValue("Bearer",accessToken);
await Task.FromResult<string>(null);
}));
eventResult = await service.Users[connectedAccountEmailID].Calendars[calendarId].CalendarView.Request(options)
.Select("id,subject,organizer,start,end,attendees,showas,isallday,seriesmasterid")
.Header("Prefer","IdType=\"ImmutableId\"")
.GetAsync();
我们得到的异常是
exeptionType : System.AggregateException
Status Code: 0
Microsoft.Graph.ServiceException: Code: tooManyRetries
Message: More than 3 retries encountered while sending the request.
at Microsoft.Graph.HttpProvider.<SendRequestAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.HttpProvider.<SendAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.BaseRequest.<SendAsync>d__34`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.CalendarCalendarViewCollectionRequest.<GetAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Service.Office365CalendarProviderService.<>c__DisplayClass44_0.<<GetCalendarMeetings>b__0>d.MoveNext()
我检查了代码并确认我们没有同时进行任何并行调用,但仍然遇到限制类型异常。
任何帮助将不胜感激
解决方法
此错误表示 .NET SDK 的内置重试处理程序已重试失败的请求达到最大次数(请参阅 https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/blob/2466fdca28d807b727497db7dc8c7767d513f62f/src/Microsoft.Graph.Core/Requests/Middleware/RetryHandler.cs#L132-L137)。 3 次是默认的最大重试值。
重试仅发生在特定的 HTTP 状态代码(429、503 或 504)时,因此出于某种原因,您在应用中遇到了这种情况。您可以尝试的一件事是使用 Graph Explorer 对同一用户尝试相同的 API 调用。查看该 AggregateException 上的其余字段以了解“真正的”异常是什么也可能会有所帮助。网络捕获还可能会暴露更多调试信息。
如果所有这些都不能提供答案,您可能需要联系support。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。