Getting error while reading the user by email address

BS 20 Reputation points
2024-05-07T13:44:54.2966667+00:00

Hello there,

I wanted to explore the Microsoft graph API's for creating the online meeting events via teams meeting.

Now the events must be related to respective users. To get the user i have followed below.

I have enrolled into the trial version of the Microsoft 365 along with Azure services as well. Then registered application in azure with necessary application level read permission for user. Then able to generate the able to generate the oauth token via https://login.microsoftonline.com/{client_id}/oauth2/v2.0/token. Using the generated access token as bearer for the API "User by email" to get the user id.

But, i get below error

API : https://graph.microsoft.com/v1.0/users/{emai_address}/

Response :

{

"error": {

"code": "Request_ResourceNotFound",

"message": "Resource '{email_Address}' does not exist or one of its queried reference-property objects are not present."

}

}

API permissions :

"roles": [

"User.ReadBasic.All",

"DeviceManagementManagedDevices.Read.All",

"OnlineMeetings.Read.All",

"OnlineMeetings.ReadWrite.All",

"User.ReadWrite.All",

"Calendars.Read",

"Directory.ReadWrite.All",

"DeviceManagementServiceConfig.Read.All",

"User.EnableDisableAccount.All",

"User.Invite.All",

"Directory.Read.All",

"User.Read.All",

"DeviceManagementServiceConfig.ReadWrite.All",

"Calendars.ReadBasic.All",

"DeviceManagementConfiguration.Read.All",

"DeviceManagementManagedDevices.ReadWrite.All",

"Directory.Write.Restricted",

"User.Export.All",

"Calendars.ReadWrite",

"User.ManageIdentities.All",

"DeviceManagementConfiguration.ReadWrite.All",

"DeviceManagementManagedDevices.PrivilegedOperations.All",

"DeviceManagementApps.ReadWrite.All",

"DeviceManagementApps.Read.All"

],

the email address used in the above request is same as the address used during the registration of the account in office 365 and Azure portal.

Where am I going wrong.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,573 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 110.2K Reputation points MVP
    2024-05-07T15:14:39.7433333+00:00

    Graph does not work with email addresses, the closest you can get to using the email value is the UPN (UserPrincipalName), but they're not guaranteed to match. If you have used a personal/consumer account when registering the trial, your UPN will be in the form user_domain_com#EXT#@tenant.onmicrosoft.com, for example.

    Do a LIST query against the /users endpoint and fetch the id and userPrincipalName values for the user(s) in question, then use them in your request.

    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.