Is there a Microsoft Graph API to filter and search messages in the same API?

Kognitos 0 Reputation points
2023-02-28T05:29:46.7066667+00:00

I am looking at a use case where a single API helps with filtering and searching simultaneously.

E.g. Search all unread emails with subject "Blah".

When I use $search and $filter in the list messages API, I get the following error:

{'error': {'code': 'SearchWithFilter','message': "The query parameter '$filter' is not supported with '$search'."}}
Microsoft Graph Applications API
Microsoft Graph Applications API
A Microsoft API that enables you to manage these resources and actions related to applications in Azure Active Directory.
493 questions
Microsoft Graph Mail API
Microsoft Graph Mail API
A Microsoft API that supports accessing data in users' primary mailboxes and in shared mailboxes.
728 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 20,376 Reputation points
    2023-02-28T07:00:48.05+00:00

    Hi @Kognitos

    The /messages endpoint does not yet support the combination of $filter and $search. For this case, you only need to use the $filter query parameter to filter:

    https://graph.microsoft.com/v1.0/me/messages?$filter=isRead eq false and subject eq 'Blah'
    

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.