Graph API /me/messages/{id} returns 404 for specific users (works for others)

Rocktim Rajkumar 0 Reputation points
2025-07-31T17:55:58.4666667+00:00

I am reaching out regarding an issue we're experiencing with the Microsoft Graph API for certain users.

We are able to successfully call the following endpoint to retrieve messages:

GET https://graph.microsoft.com/v1.0/me/messages

However, when we attempt to retrieve a specific message by its ID using:

GET https://graph.microsoft.com/v1.0/me/messages/{id}

we receive a 404 Not Found response for some users.

We are generating the message ID using the Office.js API as shown below:

if (Office.context.mailbox.diagnostics.hostName === 'OutlookIOS') {
  // itemId is already REST-formatted.
  return Office.context.mailbox.item.itemId;
} else {
  return Office.context.mailbox.convertToRestId(
    Office.context.mailbox.item.itemId,
    Office.MailboxEnums.RestVersion.v2_0
  );
}

We are also using the following endpoint to generate the Microsoft Graph access token:

https://login.microsoftonline.com/common

This issue only affects certain users. Some may be hosted on Exchange Online, while others could be using on-premise or hybrid Exchange configurations.

We would like to understand:

Why would a message ID generated as shown above result in a 404 when used with /me/messages/{id}?

Could this be related to hybrid environments or unsupported mailbox types (e.g., on-prem Exchange)?

  1. Are there any known issues or limitations when using Graph or way the item id is generated

Please advise on how to properly determine if a user is eligible for Graph-based message access and how we can handle this scenario reliably.

Thank you for your support.

Microsoft 365 and Office | Development | Office JavaScript API
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Jack-Bu 2,610 Reputation points Microsoft External Staff Moderator
    2025-08-01T13:04:32.1733333+00:00

    Hello Rocktim Rajkumar,

    Thank you for reaching out to the Microsoft Q&A Community. I understand you're experiencing an issue where the Graph API endpoint /me/messages/{id} is returning a 404 error for certain users, while working correctly for others. I am happy to assist you with that.  

    The issue you're encountering with the Graph API returning 404 for /me/messages/{id} on specific users is likely due to their mailboxes being hosted on-premises in a hybrid Exchange setup, where Graph API access is not supported (deprecated since July 2023). The message ID generation via Office.js is correct for Exchange Online, but Graph can't access on-prem mailboxes, resulting in the error.

    To determine eligibility and handle reliably:

    • Check Office.context.mailbox.restUrl in your code—if defined, the mailbox supports Graph/REST; otherwise, fall back to EWS.
    • Example code for detection:
    if (Office.context.mailbox.restUrl) {
      // Use Graph with converted REST ID
    } else {
      // Fallback to EWS with original itemId and makeEwsRequestAsync
    }
    
    • Long-term: Migrate affected mailboxes to Exchange Online for full Graph support.

    For more details, see Microsoft docs on Graph limitations for hybrid environments. If this doesn't resolve it, share the full error response body. I’d be happy to assist further.


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

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.