Using Graph API to search email body content for string that has a hash

Paul Hawkes 0 Reputation points
2023-10-13T15:41:36.18+00:00

I am searching an inbox looking for the term "#resolved" in the body of the email - I would like an exact match for the search string.

I have used this :https://graph.microsoft.com/v1.0/me/messages?$search="body:#resolved" This GET request will return nothing.

If I percent encode the # tag: https://graph.microsoft.com/v1.0/me/messages?$search="body:%23resolved" then this GET will return all mail with "resolved" in the body ignoring the # tag.

What should I be doing to just return the emails that have #resolved in their body?

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

1 answer

Sort by: Most helpful
  1. v-pd 5 Reputation points Microsoft Vendor
    2023-11-23T20:13:05.13+00:00

    When you use https://graph.microsoft.com/v1.0/me/messages?$search="body:#resolved", the API is likely treating #resolved as a special syntax, hence returning no results. When you percent encode the # tag: https://graph.microsoft.com/v1.0/me/messages?$search="body:%23resolved", the API ignores the # tag and returns all mail with “resolved” in the body.

    0 comments No comments