Forum Discussion

Samiron Mallick's avatar
Samiron Mallick
Copper Contributor
Oct 10, 2018

How to fetch office365 unread emails using postman

I am trying to fetch unread emails from inbox of my office365 account using postman.

With the help of Microsoft Graph API reference i am able to generate access token as in below format:

 

POST https://login.microsoftonline.com/{{AAA_UID}}/oauth2/token

{
    "token_type": "Bearer",
    "expires_in": "3600",
    "ext_expires_in": "0",
    "expires_on": "1539180610",
    "not_before": "1539176710",
    "resource": "https://graph.microsoft.com",
    "access_token": <ENCRYPTED_TOKEN>
}

However my requirement is to fetch unread mails from Inbox. 

 

Using the following link seems that can be possible, however while using in postman, getting "Invalid authentication, access token is empty" error.

 

https://graph.microsoft.com/v1.0/me/mailFolders('Inbox')/messages?$select=sender,subject

Can anyone please tell me how to append access token with the above code, if this is the right one.

 

Or if you know any simple and better procedure to fetch unread emails from office365 account, please advice.

3 Replies

  • You add the token to an auth header, something like this:

     

       'Content-Type'='application\json'
       'Authorization'="Bearer aaaaaaaaaaaaaaaaa"
    
    • Samiron Mallick's avatar
      Samiron Mallick
      Copper Contributor

      While doing so with the below code:

      GET /v1.0/me/messages HTTP/1.1
      Host: graph.microsoft.com
      Content-Type: application\json
      Authorization: Bearer eyJ0eXAiOiJK..................

      Getting below error. Have I missed anything?

      {
      "error": {
      "code": "UnknownError",
      "message": "",
      "innerError": {
      "request-id": "bafebf1b-9c36-4571-81be-29d54468b172",
      "date": "2018-10-10T19:36:40"
      }
      }
      }
      • VasilMichev's avatar
        VasilMichev
        MVP

        No idea, sorry. UnknownError doesn't give us much to work with :)

Resources