none
EWS has started returning 401 Authorisation Error to outlook email requests but user-id and password are still valid RRS feed

  • Question

  • i raised this question on Microsoft Online Services  >  Microsoft Online: Exchange Online and after almost one week your colleague advised me to re-post on this thread. Please see issue below. Since raising initial issue it is confirmed from my IT department that they have made no changes on my application server, so i would like to know if anything has changed on your side (see below for more info):

    Original post: 18 Sep:

    Nothing has changed in the application software. The user account is not changed and has been working fine. Password is still valid and not changed. Then on Sep 11 I started getting authorisation errors 401 each time i tried to send or fetch emails.

    Key code snippets (code not recently changed and it has worked fine for year(s) now, but suddenly errors started appearing):

    emc = New ExchangeService(ExchangeVersion.Exchange2013_SP1)
    emc.Credentials = New WebCredentials(eMailUserName, pwd)     
    emc.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx")

    Dim MyMsg As New EmailMessage(emc)
    MyMsg.Subject = eMailSubject
    MyMsg.Body = eMailHTMLbody
    MyMsg.ToRecipients.Add(eMailTo)MyMsg.Importance = Importance.High
    MyMsg.From = New EmailAddress(MyEmailAddress)
    MyMsg.ReplyTo.Add("NoReply." & MyEmailAddress)
    MyMsg.Send()

    Fails at this point with Error Code: The request failed. The remote server returned an error: (401) Unauthorized.

       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
       at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
       at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling)
       at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
       at Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition)
       at Microsoft.Exchange.WebServices.Data.EmailMessage.Send()
       at ....

    Please advise if there is something that has changed in outlook EWS from 11 September onwards. I cannot find any relevant article or info via google. 

    I am also checking with our IT department if they have made any changes. There was a discussion around certificates - could this have anything to do with it if the server certificate has been changed?

    Anyway, please advise from your side.

    Thanks, Keith227


    Keith227

    Wednesday, September 25, 2019 5:49 PM

All replies

  • I would suggest you try the account your trying to use with the EWSEditor https://blogs.msdn.microsoft.com/webdav_101/2018/05/10/ewseditor-1-20-released/ that will give you another point of reference. Also https://testconnectivity.microsoft.com/ can be used, also can you logon with those credentials to OWA ?

    Cheers
    Glen

     
    Wednesday, September 25, 2019 11:19 PM
  • hi Glen

    i tried using the testconnectivity link above, and the test failed (Unauthorised 401)

    Exchange Web Services service account access verification

      The Microsoft Connectivity Analyzer failed to complete all tests with the service account.
     
    Additional Details
      Elapsed Time: 38 ms.
     
    Test Steps
     
    A new mail item is being created.
      The attempt to create a mail item failed.
     
    Additional Details
     
    Exception details:
    Message: The request failed. The remote server returned an error: (401) Unauthorized.
    Type: Microsoft.Exchange.WebServices.Data.ServiceRequestException
    Stack trace:
    at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
    at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
    at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
    at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling)
    at Microsoft.Exchange.WebServices.Data.ExchangeService.CreateItem(Item item, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
    at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
    at Microsoft.Exchange.WebServices.Data.Item.Save(FolderId parentFolderId)
    at Microsoft.Exchange.Tools.ExRca.Tests.CreateItemTest.PerformTestReally()
    Exception details:
    Message: The remote server returned an error: (401) Unauthorized.
    Type: System.Net.WebException
    Stack trace:
    at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
    at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.<ExecuteRequestAsync>d__64.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse()
    at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)

    Elapsed Time: 38 ms.


    This is absolutely ridiculous as i log in to the account normally and it works fine, just via EWS i get unauthorised and only since 11 Sep.

    Any other suggestions?

    /Keith.


    Keith227

    Thursday, September 26, 2019 8:27 AM
  • Any Solution?
    Friday, November 22, 2019 5:09 PM
  • Did you ever find a solution to this issue?
    Tuesday, June 30, 2020 7:37 PM