none
Keep getting 401 unauthorized for mail.send POST requests RRS feed

  • Question

  • I want to delegate sending email messages from my company email address using the REST API, but I keep getting the 401 unauthorized error in Postman.

    What I did:

    Set up using the "Application Registration Portal", with "Mail.Send" and "User.Read" as delegated permissions. When logging in I see that I'm approving access to both permissions.

    Tested the connection using GET https://graph.microsoft.com/beta/me, with the authorization token in the header. This works (I get info lots of about my email address). So I assume that callback URL, Auth URL, Access token URL, Client ID, Client secret have all been set up correctly. The scope field of the access token shows both "Mail.Send" and "User.Read".

    But for some reason POST https://outlook.office.com/api/v2.0/me/sendmail does not work. My access token keeps getting rejected. (1) Please advise on how to get my token accepted.

    (2) Could it be that the admin of my organisation has forbidden this usage? If yes, how could I verify this?

    Additional info, Auth URL: https://login.windows.net/common/oauth2/authorize?resource=https%3A%2F%2Fgraph.microsoft.com; Access token URL: https://login.windows.net/common/oauth2/token

    Friday, February 10, 2017 12:50 PM

All replies

  • Hi,

    Thanks for posting here.

    Since your issue is about Office 365 REST API, I would move this thread into Office 365 for developers forum:

    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=Office365forDevelopers

    Sorry for any inconvenience.  

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 13, 2017 1:59 AM
    Moderator
  • Hi,

    What code do you use?


    Regards, Sjoukje

    Please remember to click 'Mark as Answer' on the post that helps you.

    Thursday, February 16, 2017 10:57 AM
    Moderator
  • Thank you for your reply, Sjouke,

    I am using the sample request with subject "Meet for lunch?" from https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations#SendMessages.

    I only changed the recipient address to my work email address (same as the address I used to login).

    Friday, February 17, 2017 8:52 AM