Getting Error Code: ErrorInvalidUser when trying to get message using GET /v1.0/users/{user-email}/messages/{message-id}

Piyumi Perera 121 Reputation points
2022-10-20T03:14:42.737+00:00

I am using an Outlook Add-in which follows SSO as the authentication service and On Behalf Of Flow as the authentication grant flow . When retrieving the message using graph API I am getting following error for some Azure AD users.

Code: ErrorInvalidUser  
Message: The requested user 'abc@testdomain.com' is invalid.  

252188-image.png

I am using following API call to get message.

https://graph.microsoft.com:443/v1.0/users/{user-email}/messages/{message-id}?$select=subject%2C%20body%2C%20internetmessageheaders%2C%20parentFolderId

They are using Microsoft O365 MSO (Cloud) offering a Microsoft Office E3 license.

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.
3,963 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,065 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Bhanu Kiran 3,611 Reputation points
    2022-10-20T05:58:58.947+00:00

    Hi @Piyumi Perera ,

    The above error code tells that the above user is invalid or doesn't exist. Check whether the user exists in portal.office.com

    If the user exists, using this endpoint GET https://graph.microsoft.com/v1.0/users, you can query all the users in your tenant. In the response, The response contains id and userPrincipalName that can be used to request the /messages endpoint. Have you tried using other users on this issue?

    You can refer to this documentation to get a token.

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


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.