504 Error getting messages from shared mailbox

Kaczmarek, Dan 20 Reputation points
2025-01-27T21:53:26.7966667+00:00

I'm trying to get a message from a shared mailbox with the graph api

curl -X GET "https://graph.microsoft.com/v1.0/me/messages/<message-id-here>/\$value" \
     -H "Authorization: Bearer <graph-api-key-here>" \
     -H "Content-Type: application/json" \
     -H "Prefer: outlook.allow-unsafe-html" \
     -v


{"error":{"code":"UnknownError","message":"","innerError":{"date":"2025-01-27T21:37:28","request-id":"fbbc7986-2d63-4a0e-a511-1a017705a043","client-request-id":"fbbc7986-2d63-4a0e-a511-1a017705a043"}}}

It takes 30 seconds for the request to complete and the error to show up. Feels like a timeout but the message I'm trying to retrieve is very small.

The same token retrieves (much larger) messages from a non-shared mailbox near instantly.

I checked the scopes and it does have the Mail.ReadWrite.Shared scope as expected.

The user getting the token has full permissions on the shared mailbox

Why am I unable to retrieve messages from the shared mailbox?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,309 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,320 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yakun Huang-MSFT 10,555 Reputation points Microsoft External Staff
    2025-01-28T06:02:18.86+00:00

    Hello Kaczmarek, Dan,

    Thank you for reaching out to Microsoft Support!

    For the mail obtained from the shared mailbox, it is expected that the mail in the shared mailbox cannot be obtained through the /me endpoint.

    It is recommended that you obtain the mail according to the document and use the user_id to obtain the mail shared by the user.

    Please see the link for details but be careful to ensure that the user has successfully shared the email to you.

    https://learn.microsoft.com/en-us/graph/outlook-share-messages-folders

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.