【发布时间】:2021-04-22 18:58:58
【问题描述】:
当我们尝试使用 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()
我检查了代码并确认我们没有同时进行任何并行调用,但仍然遇到限制类型的异常。
任何帮助将不胜感激
【问题讨论】:
-
对 Azure 没有任何内幕,但我注意到状态码是 0。即使图 API 服务器没有发送 HTTP 码 429 来指定过多的请求,它也会 (可能)仍然发送 0 以外的内容。因此,除非您使用的库解析响应不正确,否则 A.)您的请求永远不会到达服务器或 B.)服务器会立即关闭连接。如果您有能力这样做,您可以尝试在请求期间运行wireshark,或者通过调试器单步执行以查看库在哪个阶段停止。
标签: microsoft-graph-api azure-ad-graph-api office365api