How to Filter Query Results from Microsoft-Graph-People?

Tony Lockhart 1 Reputation point
2022-07-26T14:31:37.117+00:00

Hi Support,

I am trying to query the Microsoft API for a specific user's email within my organization. Therefore, I have created the following query, to return the displayName and scoredEmailAdresses for user "jane doe", whose scoredEmailAddresses endsWith @pearson.com (see below). However, when I run this query in Graph Explorer, I receive the error below. Can any advise how I can fix this query?

Query:

https://graph.microsoft.com/v1.0/me/people?$search="jane doe"&$select=displayName,scoredEmailAddresses&$count=true&$filter=endsWith(scoredEmailAddresses,'@pearson.com')

Error:

 {  
     "error": {  
         "code": "BadRequest",  
         "message": "Invalid filter clause",  
         "innerError": {  
             "date": "2022-07-26T14:16:45",  
           }  
      }  
 }  
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,520 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 36,736 Reputation points
    2022-07-27T03:28:45.63+00:00

    Hi @Tony Lockhart

    You can't filter the scoreEmailAddresses property directly because it's a collection, and the collection can only be iterated over using the lambda operator.

    GET https://graph.microsoft.com/v1.0/me/people?$search="jane doe"&$select=displayName,scoredEmailAddresses&$count=true&$filter=scoredEmailAddresses/any(s:s/address eq 'address')  
    ConsistencyLevel: eventual  
    

    225112-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.