Share via

Why doesn't user from /users endpoint get returned when `startsWith` doesn't have enough characters?

Aron Hegedus 26 Reputation points
2022-03-30T14:00:42.067+00:00

When I send a request to
https://graph.microsoft.com/v1.0/users?$count=true&$filter=businessPhones/any(p:startsWith(p, '%2B44 (20)'))&$top=999&$search="displayName:John Smith"
(searching for John Smith with a number that starts with "+44 (20)"

I get the results

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(displayName,businessPhones,mobilePhone,id)",
"@odata.count": 1,
"value": [
{
"displayName": "John Smith",
"businessPhones": [
"+44 (20) 12341234"
],
"mobilePhone": null,
"id": "1234c123-12bb-12aa-1234-50a50b50a50b"
}
]
}

However when I only specify the first 3 letters of the businessPhones,
https://graph.microsoft.com/v1.0/users?$count=true&$filter=businessPhones/any(p:startsWith(p, '%2B44'))&$top=999&$search="displayName:John Smith"&$Select=displayName,businessPhones,mobilePhone,id

(searching for John Smith with a number that starts with "+44"

I get

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(displayName,businessPhones,mobilePhone,id)",
"@odata.count": 0,
"value": []
}

Why is this? The same user should be returned to me. If I just query the /users endpoint, I get 1.6 million people returned.
I am using %2B because that's the html encoding for "+", which I need there, otherwise I can't search on it.

PS the id/phone/name was changed from the real user I'm using for privacy reasons.

Microsoft Security | Microsoft Graph
0 comments No comments

2 answers

Sort by: Most helpful
  1. Aron Hegedus 26 Reputation points
    2022-03-31T09:33:59.363+00:00

    Thank you for the response!

    Unfortunately clearing the cache and cookies didn't help. I am using the headers ConsistencyLevel: eventual (they are the only headers, and the query doesn't work without it).
    I am still getting it to repro. If I ask for users with businessPhones starting with "+44", and no $search, the person I'm searching for appears. But as soon as I add &$search="displayName:John Smith", I get 0 results back, until I specify the number to startsWith up to "+44 (2".

    I have repro-d this with a different user as well, who's phone also starts with "+44 (20)". And again, if I search
    https://graph.microsoft.com/v1.0/users?$count=true&$filter=businessPhones/any(p:startsWith(p, '%2B44 (2'))&$top=999&$Select=displayName,businessPhones,mobilePhone,id&$search="displayName:Rochelle Reid"

    Then I get 1 result back. However, it I do

    https://graph.microsoft.com/v1.0/users?$count=true&$filter=businessPhones/any(p:startsWith(p, '%2B44'))&$top=999&$Select=displayName,businessPhones,mobilePhone,id&$search="displayName:Rochelle Reid"

    Then I get 0 results.

    Removing the $Select and $top doesn't make any difference.

    Can you please try and repro this with someone with more than just 1 name please? You might need to delete more numbers than me for the number, but I'm interested in whether this is just for me.

    Was this answer helpful?


  2. CarlZhao-MSFT 46,456 Reputation points
    2022-03-31T06:33:15.037+00:00

    Hi @Aron Hegedus

    I've tested it locally and it doesn't seem to be a problem. Can you clear your browser cache and use Graph Explorer to call that api test? Also, don't forget to add the ConsistencyLevel : eventual request header.

    188556-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.