question

HarshVats-5143 avatar image
0 Votes"
HarshVats-5143 asked Deva-MSFT answered

Getting exception while fetching busy time from calendar. Microsoft.Graph.ServiceException: Code: tooManyRetries. exeptionType : System.AggregateException. Status Code: 0

When I am trying to fetch meetings from Calendar using Graph API I am getting exceptions randomly for multiple users

Code for fetching calendar events:

 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();


The exception I am getting a few time for multiple users (daily up to 50-60 times approx)

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()


I have checked the code and verified that we are not making any parallel calls at the same time but still getting throttled limit type exceptions.
I have checked the same through Graph Explorer and not getting this exception. Urgent help will be appreciated.

microsoft-graph-sdkmicrosoft-graph-calendar
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Deva-MSFT avatar image
0 Votes"
Deva-MSFT answered

Have you looked at the throttling guidance? Also, if you use our SDKs, there is built in middleware that will handle this for you; check out the documentation and the best practices shared in it.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.