1

I want to search email using Graph API in my own developed application. By referring to these threads - Graph Api: Region is required when request with application permission , How to use Graph API Sharepoint Search from console app , Search content with application permissions , I tried to run the search which resulted in Application permission is only supported for the following entity types:site, list, listItem, drive and driveItem. (Request and response json is below).

Does it mean that using an app like a console application developed in C# will not be able to search the emails (as message is not mentioned in error response - only these are mentioned: site, list, listItem, drive and driveItem) even if it has required secret, auth token and permissions?

Request: URL : https://graph.microsoft.com/beta/search/query
Request Payload:

{
  "requests": [
    {
      "entityTypes": [
        "person"
      ],
      "query": {
        "queryString": "contoso"
      },
      "Region" : "NAM",
      "from": 0,
      "size": 25
    }
  ]
}

Response:

{
    "error": {
        "code": "System.UnauthorizedAccessException",
        "message": "Application permission is only supported for the following entity types:site, list, listItem, drive and driveItem.",
        "target": "",
        "httpCode": 403
    },
    "Instrumentation": {
        "TraceId": "7174e417-a2fe-02e5-1523-1fcda7a66886"
    }
}
Sandeep Bhutani
  • 589
  • 7
  • 23
  • I only found [this api](https://learn.microsoft.com/en-us/graph/search-concept-messages#known-limitations) for searching oneself's messages and [this api](https://learn.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0&tabs=http#http-request) for searching a specific users' messages – Tiny Wang Dec 20 '22 at 02:40
  • Second API is the one which we are already using.. can we use List messages api to search for specific text in body or attachments? – Sandeep Bhutani Dec 20 '22 at 06:25
  • I'm afraid not.... but I think you can also test it in your app, because you have so many emails for testing. – Tiny Wang Dec 20 '22 at 07:38

0 Answers0