https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/messages

Andrew Sleat 5 Reputation points
2024-04-12T08:44:06.4333333+00:00

When I request https://graph.microsoft.com/v1.0/users with a Bearer Token obtained from https://login.microsoftonline.com/{Tenant ID}/oauth2/v2.0/token with the body keys and values required (client_id, scope, client_secret and grant_type) I get my user id and userPrincipalName.

However when I request https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/messages with the id I get this response:

{"error":{"code":"OrganizationFromTenantGuidNotFound","message":"The tenant for tenant guid 'tenant_id' does notexist.","innerError":{"oAuthEventOperationId":"a3908efa-b3d4-4382-b927-37863fcdf30b","oAuthEventcV":"sO9q9uoSflGP9ahgyFEX6Q.1","errorUrl":"https://aka.ms/autherrors#error-InvalidTenant","requestId":"6a566e11-6c63-4e38-9192-3378e4db4187","date":"2024-04-12T08:33:17"}}}

And when I request https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/messages with the userPrincipalName I get

{
    "error": {
        "code": "Request_ResourceNotFound",
        "message": "Resource 'email' does not exist or one of its queried reference-property objects are not present.",
        "innerError": {
            "date": "2024-04-12T08:41:37",
            "request-id": "db0de18f-aa62-40f3-926a-517b02277147",
            "client-request-id": "db0de18f-aa62-40f3-926a-517b02277147"
        }
    }
}

I have a Microsoft 365 subscription. What am I doing wrong?

Outlook | Windows | Classic Outlook for Windows | For business
Microsoft Security | Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. Andrew Sleat 5 Reputation points
    2024-04-12T09:10:43.8933333+00:00

    You need an Office 365 E3 Developer license for anyone encountering the same problem. They don't make this crystal clear. You may also need to setup an organisational account instead of a personal account.

    1 person found this answer 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.