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 Security | Microsoft Graph
0 comments No comments
{count} votes

Answer accepted by question author
  1. Srinivasa Rao Darna 6,846 Reputation points Microsoft External Staff
    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.com" AND to:******@test.com”
    With $search="subject:Request*** AND from:******@test.com AND to:******@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 47,586 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 &


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.