Search code examples
c#microsoft-graph-apioutlook-api

Set TimeOut to a higher value in Microsoft.Graph SDK


I get timeout error frequently with the below code using the Microsoft.Graph package,

await graphServiceClient.Users[UserId].Contacts.Request().AddAsync(contact);

As there are no option (that I could find) for adding multiple contacts at a time, I was calling the above LOC parallel. I have around say 500 contacts to import and many of them fails giving the timeout response

Exception: Code: timeout Message: The request timed out.

Are there any option to set TimeOut to a higher value in Microsoft.Graph GraphServiceClient?


Solution

  • You can set the Timeout to a higher value like this: For example to set the Timeout to one hour:

    graphServiceClient.HttpProvider.OverallTimeout = TimeSpan.FromHours(1);