An internal server error occurred. The operation failed. connecting to O365 Exchange using

Dashore, Nitesh 1 Reputation point
2022-09-07T12:28:45.653+00:00

Hello,

We changes the authentication mode from Basic to Oatuh for our EWS exchange service.

Very often I am getting internal server error while connecting to office365 account.
I am not able to understand what is this and why is this happening so frequently.

Cannot access mailbox for service account: Microsoft.Exchange.WebServices.Data.ServiceResponseException: An internal server error occurred. The operation failed.
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException) in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\Requests\ServiceRequestBase.cs:line 990
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\Requests\ServiceRequestBase.cs:line 827
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request) in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\Requests\ServiceRequestBase.cs:line 724
at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\Requests\MultiResponseServiceRequest.cs:line 157
at Microsoft.Exchange.WebServices.Data.ExchangeService.BindToFolder(FolderId folderId, PropertySet propertySet) in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\ExchangeService.cs:line 278
at Microsoft.Exchange.WebServices.Data.ExchangeService.BindToFolderTFolder in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\ExchangeService.cs:line 295
at Microsoft.Exchange.WebServices.Data.Folder.Bind(ExchangeService service, WellKnownFolderName name) in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\ServiceObjects\Folders\Folder.cs:line 89

Can anyone have any idea about this ?

Exchange | Exchange Server | Development
Exchange | Exchange Server | Management
{count} votes

2 answers

Sort by: Most helpful
  1. Jame Xu-MSFT 4,191 Reputation points
    2022-09-08T06:00:21.947+00:00

    Hi @Dashore, Nitesh ,
    You could try to add a header after setting ImpersonalteUserId service.HttpHeaders.Add("X-AnchorMailbox", mailbox.Mailbox);
    Recently it seems that quite a few people have encountered this problem, you may refer to this article:
    https://techcommunity.microsoft.com/t5/exchange/ews-with-oauth-quot-an-internal-server-error-occurred-the/m-p/3609047


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Dashore, Nitesh 1 Reputation point
    2022-09-16T09:22:45.553+00:00

    Hi @Jame Xu-MSFT

    I do nothave any issue in developing the software. my application is working and using EwsManagedApi, i am able to read the emails but only once in a 505 time I get the error what I mentioned above.
    This starts happening after the authentication change from basic to OAuth.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.