KQL search messages for phrase in body with groups of numbers throws an error

James Pace 0 Reputation points
2024-11-27T16:36:17.89+00:00

I am trying to search an email for a product code, but the API returns a 500 error:

{
    "error": {
        "code": "ErrorInternalServerError",
        "message": "An internal server error occurred. The operation failed., Invalid entry ('invalid') in parent stack: or(searchPhrase(@, @), searchPhrase(@, @)))"
    }
}

The URL is correctly formatted, with all the URL encoding and escaping required.

The text I'm trying to search for which appears exactly in the subject or body is P100.112.339.5. Since I want to whole phrase to match, I've quoted it "P100.112.339.5", and that is being included as a KQL expression on the body:

body:\"P100.112.339.5\"

Rather strangely, if I change the field from body to subject it works fine. Unfortunately I need to search for this string in the body and the subject.

Keeping the field as body, I get mixed results by removing some of the characters rather arbitrarily:

KQL Expression Result
body:"P100 112 5" Same error as before
body:"P100 112 " No error, but doesn't match so not helpful
body:"P100 112" No error, but doesn't match so not helpful
body:"P100 112 50" Same error as before
body:"P100 112 500" No error, but doesn't match so not helpful
body:"P100 112 5000" Same error as before
body:"P100 112 50000" Same error as before
body:"P100 112 500000" Same error as before

So there is something really weird going on with the Graph API. It only seems to like groups of numbers if they are 3 digits long, as shown by the last few example of padding my search text with zeros. Is it trying to coerce the value to an IP address or something?

The examples also show it's not the periods "." which are causing the issue, as the periods were removed from these examples.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,507 questions
{count} votes

Your answer

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