Warm tip: This article is reproduced from stackoverflow.com, please click
microsoft-graph microsoft-graph-mail outlook-api

"UnknownError " while accessing Graph API to get mailbox messages of the specific user with grant ty

发布于 2020-04-11 11:40:18

I am trying to get the messages from outlook mailbox of a specific user. I created an app with permissions type "application" and permissions Mail.ReadBasic.All, Mail.Read, Mail.ReadWrite. I provided adminconsent with below url:

https://login.microsoftonline.com/{tenant}/adminconsent?client_id={}&secret_id={}&state=12345&redirect_uri=http://localhost:3000/myapp

and it returned adminconsent=true.

I am able to generate the token with https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token.

But when acccessing graph api I am getting unknown error.

https://graph.microsoft.com/v1.0/users/{mail id}/mailfolders/inbox/messages
Header : Authorization = Bearer ey....

Error:

{   "error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
      "request-id": "62f75bdd-948b-4f35-a400-cbc1650d37f7",
      "date": "2020-01-31T07:00:00"
    }   } }
Questioner
Naveen Yalla
Viewed
71
Naveen Yalla 2020-02-04 20:07

Results coming for some users and not coming for others is because their mail boxes setup.

Graph APIs work for Office 365 mail boxes which are saved in cloud.

So on premises mail boxes will not work for Graph APIs to read mails. Better exception other than Unknown error from the MS team much appreciated in terms of issue debugging.