Specify Body in Microsoft Search API Email RESPONSE

Chukwuma Obi 41 Reputation points
2022-09-27T00:25:30.667+00:00

Please I noticed the search API has BodyPreview. I will like to get the body, is there a way I can specify this in the request.

https://learn.microsoft.com/en-us/graph/search-concept-messages#response

@Srinivasa Rao Darna

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

Accepted answer
  1. Srinivasa Rao Darna 6,681 Reputation points Microsoft Vendor
    2022-09-27T17:37:47.79+00:00

    Hi @Chukwuma Obi ,

    Using Search message graph API endpoint, bodyPreview is of type string and it will contain the first 255 characters of the message body. It is in text format. And body is of type "@odata.type": "microsoft.graph.itemBody" which cannot be retrived through search result even by using search-api-overview-get-selected-properties.

    To get the message body, First we have to call the we have to call the search query message graph API and get the hitid property of respective message from the response then use hitid in messages graph API call.

    POST /search/query   
    {  
        "requests": [  
            {  
                "entityTypes": [  
                    "message"  
                ],  
                "query": {  
                    "queryString": "paul@abc.com"  
                }  
            }  
        ]  
    }  
    

    245186-image.png

    • Subsequently make another GET /me/messages/{hitId} to get the message body in HTML format hitId returned in previous call.

    245136-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 person found this answer helpful.

0 additional answers

Sort by: Most helpful