AND is not working in the search for graph api

Anonymous
2022-09-23T10:24:18.67+00:00

API:
https://graph.microsoft.com/v1.0/users/a12*********/mailFolders/Inbox/messages?$search="subject:Request***" AND "from:test@test .com" AND "to:test@test .com"

I am using multiple conditions in the search with graph api. However, the AND condition is not working as expected. It is giving result when either of the criteria is met like OR.

Can you please check and can provide some solution

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,889 questions
0 comments No comments
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,696 Reputation points Microsoft Vendor
    2022-09-26T17:26:01.387+00:00

    Hi @Anonymous ,

    I think there is a small correction to the condition’s syntax in search query.

    Replace $search="subject:Request***" AND "from:test@test.com" AND to:test@test.com”
    With $search="subject:Request*** AND from:test@test.com AND to:test@test.com"
    Put all conditions within "" not like $search=”condition1” AND “Condition2” AND “condition3”

    Response with AND conditions in search query:
    244856-image.png

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


1 additional answer

Sort by: Most helpful
  1. Olaf Helper 41,571 Reputation points
    2022-09-23T10:42:12.12+00:00

    the AND condition is not working as expected

    Why do you think AND is the key for a logical operator in the URL? It's the ampersand sign &