504 Gateway Timeout When Getting Large Attachments From Email In Microsoft Graph API

Piyush Chugh 5 Reputation points
2023-05-09T21:48:54.9033333+00:00

I am trying to get an attachment of an email, but Microsoft Graph API is responding with 504 Gateway Timeout Error.

Details:

  • The mailbox is part of a paid Microsoft 365 account.
  • This issue is reproducible for a large attachment ~ 45-50MB in size.
  • It is a shared mailbox, accessed by an Azure app that has Application Permissions to read emails in this mailbox.
  • The Message Size Restriction setting under the Exchange Admin page has been set at 153600 KB for this mailbox.
  • The same request is working fine for a smaller attachment (less than 10 MB).
  • This failure always occurs around the 30-second time.

URL:

GET  https://graph.microsoft.com/v1.0/users/[EMAIL}/messages/[OUTLOOK_ID}/attachments/[ATTACHMENT_ID]/$value

Headers:

KeyValueAuthorizationBearer [TOKEN]PreferIdType="ImmutableId"### Response:

{
    "error": {
        "code": "UnknownError",
        "message": "",
        "innerError": {
            "date": "2023-05-09T20:29:44",
            "request-id": "[HIDDEN]",
            "client-request-id": "[HIDDEN]"
        }
    }
}

  • Separately, on another Microsoft 365 trial account, using a similar request I am easily able to read attachments that are even greater than 100 MB.

It would be great if somebody can pinpoint the root cause of this problem and help me fix it.

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,365 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,464 questions
{count} votes