oauth-2.0outlookmicrosoft-graph-apioutlook-restapimicrosoft-graph-mail

microsoft graph API - $filter with from email & $search


I need a Microsoft graph API query to retrieve mails based on from email filter & contains a particular word.

There are ready API's to do these thing individually.

To retrieve mails based on from - email address:

https://graph.microsoft.com/v1.0/me/messages?$filter=(from/emailAddress/address) eq 'member_services@outlook.com'

To retrieve mails based on a search term

https://graph.microsoft.com/v1.0/me/messages?$search=get

But I need a query that does the both together.

I tried combining them with '&' but it's not working.

https://graph.microsoft.com/v1.0/me/messages?$search=get&$filter=(from/emailAddress/address) eq'member_services@outlook.com'

This query is giving bad request error.

enter image description here

Please help me with a proper query that works.


Solution

  • You are missing space after eq operator but it's not important because the query parameter $filter is not supported with $search.

    You can use only $search and specify from and the term like this

    https://graph.microsoft.com/v1.0/me/messages?$search="from:member_services@outlook.com AND get"
    

    Resources:

    Using $search on message collections