Warm tip: This article is reproduced from serverfault.com, please click

how to handle throttling with MSGraphClient while sending email

发布于 2021-01-27 15:55:46

i am using below code to send email using microsoft graph

await graphClient.Me.SendMail(message, true).Request().PostAsync()

Since post operation doesnt return anything then how to detect status code 429 (Throttle response code)and handle it.

Questioner
riks
Viewed
0
Dev 2021-01-29 21:02:30

PostAsync() method should throw a ServiceException on error. For example:

try
{
     await graphClient.Users[userId].SendMail(message).Request().PostAsync();
} 
catch (Microsoft.Graph.ServiceException e)
{
     Console.WriteLine(e.Error);
}