简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM