/me endpoint sometimes has blank 'mail' property

Leo B 6 Reputation points
2022-12-06T02:57:30.787+00:00

Got some questions about /me endpoint

  1. What are the possible reasons as to why mail will be undefined?
  2. What can be done to get a value in the mail property?
  3. If it cannot be filled, what is a viable alternative?
  4. I've checked userPrincipalName and it looks like an email, but I've noticed that for some users, it does not match the mail property which means it's not a reliable alternative. Is this correct?

Thanks.

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

1 answer

Sort by: Most helpful
  1. Vasil Michev 112K Reputation points MVP
    2022-12-06T06:49:26.18+00:00

    Simply put, not every user object within Azure AD has an email address. null is a valid value for the mail property. And userPrincipalName is a different thing altogether, not necessarily related to the mail property.

    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.