Flemin Adambukulam
Flemin Adambukulam

Reputation: 860

Microsoft Graph API: $filter & $search not working together

I'm using Graph API to look for a message in Inbox which has a particular subject and which is unread to download its attachment. I'm able to successfully search for messages with a particular subject using $search by forming this URL:

https://graph.microsoft.com/v1.0/users/myEmailId/mailFolders/Inbox/messages?$search=%22subject%3ASome%20Daily%20Email%22

And I'm able to successfully filter messages which are unread using this URL:

https://graph.microsoft.com/v1.0/users/myEmailId/mailFolders/Inbox/messages?$filter=isread%20eq%20false

But when I'm trying to combine both the query parameters, I get a Bad Request exception. I have tried using this URL :

https://graph.microsoft.com/v1.0/users/myEmailId/mailFolders/Inbox/messages?$search=%22subject%3ASome%20Daily%20Email%22&$filter=isread%20eq%20false

I have tried (I know its stupid) inverse version by placing the $filter first and then $search. And I have also tried encoding the "&" in the URL.

Please let me know how to correctly call the URL by passing both $filter and $search together.

Thanks in advance.

Upvotes: 1

Views: 3729

Answers (1)

eitamal
eitamal

Reputation: 782

The $filter parameter doesn't work with $search by design (see Microsoft Graph optional query parameters):

Note: You can currently search messages but not contacts or events. A $search request returns up to 250 results. You cannot use $filter or $orderby in a search request.

Upvotes: 2

Related Questions