microsoft-graph-apimicrosoft-graph-sdksoutlook-restapi

Downloading MIME content in Outlook Rest API is too slow


I need to download MIME contents from Outlook API in Microsoft Graph. All other requests are completely fine, but endpoint for fetching the MIME message sometimes takes too much time.

Documentation https://learn.microsoft.com/en-us/graph/outlook-get-mime-message

Endpoint I use https://graph.microsoft.com/v1.0/me/messages/{messageId}/$value

Way I call it

await _graphClient.Me.Messages["MailIdGoesHere"].Content.Request().GetAsync()

Logs for messages that take unusual time to download compared to their sizes

But not all messages are slow. Bigger messages are downloaded in less time compared to these unusual ones

I tried to batch these requests by maximum allowed number in API (20 at the moment), and result didn't change. Parsing the response messages take too much time in the end and eventually total duration is not affected.

Is there some other way to get raw MIME content of the mails in Outlook API or is it a known issue?


Solution

  • Got it.

    I was doing tens of requests at the same time. Even though they are batched and requests are done in parallel, sending 20 MIME get requests kind of breaks the Outlook API and even smaller messages take long time to return.

    I used SemaphoreSlim with 3 concurrent tasks at a time and throttled all these requests to fix this issue.