Austin Felipe
Austin Felipe

Reputation: 789

Can't find user by email using GraphAPI

I'm using GraphAPI getting users by email for months. Something happened to a specific user. Right now I can't get this user using the following approach:

signInNames/any(x:x/value eq '{email}'

This is working with all users excepting the one I said before.

I'm getting this when trying to retrieve by email:

{ 
  "odata.metadata": "https://graph.windows.net/jsmaddev.onmicrosoft.com/$metadata#directoryObjects", 
  "value":[]
}

If I try to get by ObjectId I can access user's info but the signInNames seems to be empty:

"signInNames":[]

Is there something that could cause this? You should remember that this particular access was working as intended.

Thanks!

Upvotes: 0

Views: 394

Answers (1)

Joy Wang
Joy Wang

Reputation: 42063

This is normal. The filter signInNames/any(x:x/value eq '{email}' returns the users whose signInNames.value equals the email.

The signInNames part sample:

 "signInNames": [
    {
      "type": "userName",
      "value": "AlexW"
    },
    {
      "type": "emailAddress",
      "value": "[email protected]"
    }
  ]

If I try to get by ObjectId I can access user's info but the signInNames seems to be empty

Since the signInNames property is empty, "signInNames":[], it will returns the "value":[].

enter image description here

You should remember that this particular access was working as intended.

Of course, if the signInNames is not empty, it will work fine.

enter image description here

Upvotes: 1

Related Questions