Search code examples
emailmicrosoft-graph-api

MS Graph API: Using a contains operator in query


How do I do a contains string in a graph api request?

I want to find all emails with the a subject that contains the key word 'orange' from a particular user. Something like:

https://graph.microsoft.com/v1.0/users/jane.doe@example.com/messages?$search="to:jane.doe@example.com and contains(Subject, 'orange')"&$select=subject,from,toRecipients,receivedDateTime,bodyPreview

Where can i find all the graph api operators and filters. I've taken a look at: https://developer.microsoft.com/en-us/graph/graph-explorer but only see very simple examples


Solution

  • I ran some tests. Search looks like it works like it would in Outlook. Just use key:'value' pairs with spaces inside $search

    https://graph.microsoft.com/v1.0/users/jane.doe@example.com/messages?$search="to:jane.doe@example.com Subject:'orange'"&$select=subject,from,toRecipients,receivedDateTime,bodyPreview