Forum Discussion
EWS with oAuth "An internal server error occurred. The operation failed."
Hi...
Since yesterday, my synchronization application starts throwing exceptions with the following error
"An internal server error occurred. The operation failed."
It only happen for mailboxes when I authenticatate with oAuth (CreateWithApplicationOptions).
Has anyone experienced the same and found a solution?
Tracing the call:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">*</Action>
</s:Header>
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorInternalServerError</faultcode>
<faultstring xml:lang="en-US">An internal server error occurred. The operation failed.</faultstring>
<detail>
<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorInternalServerError</e:ResponseCode>
<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">An internal server error occurred. The operation failed.</e:Message>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
- MichaelDenmarkCopper Contributor
I've found out that the problem can be solved by added a header after setting ImpersonalteUserId
service.HttpHeaders.Add("X-AnchorMailbox", mailbox.Mailbox);
- Karl_FarrugiaCopper Contributor
Thanks for sharing. This solved our issue as well
- nsgsannaCopper ContributorThis also resolved it for us.
The error message is extremely unhelpful and why is it needed is a mystery, but al least it's solved.- onlyconnectCopper ContributorSame here, thanks so much for posting. I wish there were another way to access the Exchange Online public folders programmatically ...
- anconamCopper Contributor
MichaelDenmark
We are experiencing the same. Logs in our product show that this error had a surge over the past week. Seems like a problem with MS.- denspin1982Copper Contributor
We have the same error-rates in our product:
- MikeCoopCopper Contributor
Same here, we are already using:
ewsClient.HttpHeaders.Add("X-AnchorMailbox", "{emailAddress}")
We've been getting this error for a few days now:
"Microsoft.Exchange.WebServices.Data.ServiceResponseException: An internal server error occurred. The operation failed."
It happens when calling the function:
ewsClient.ResolveName(searchStr, ResolveNameSearchLocation.DirectoryOnly, True)
The console application is running from an Azure VM.
The strange thing is, when I run the same application from my laptop locally, it works. No error.
- Kevin BrannonCopper Contributor
Same error here, but only intermittently. Odd that it cropped up seemingly just this week.
- ThinkjohnCopper Contributor
i am getting same error as well. I already include the header for the impersonated mailbox.
It is intermittent but often enough that it is a serious problem.
please post back if you find a solution.
- niteshdashoreCopper Contributor
MikeCoop I am alos getting the same error. Its working locally and getting this issue on server randomly. I will suggest you to open a ticket on microsoft.
- MacieKorteCopper Contributor
Our QA team has noticed this problem happening recently as well (started reporting Aug 29, 2022 but it probably started earlier than that). The issue is still ongoing for us.
- MacieKorteCopper Contributor
This error has stopped happening for us this week. QA has verified that it is no longer occurring over multiple days. We made no change on our side, so it was definitely a change on the Microsoft side which caused it and resolved it.
- McCrayMACopper ContributorSame thing here. We have multiple customers reporting this and we have experienced it ourselves. One customer elected to go back to UserID/Password, but that will only work until 10/1. We need an answer/update from Microsoft....
- Mikhail295Copper Contributor
I have the same issue.
And I discovered null prefix in token string in trace of EwsRequest:...wsse:Security soap:mustUnderstand='1'> nulleyJ0eXAiOiJK...
- Mikhail295Copper Contributor
We have fixed this problem:
1. Get token with scope - `https://outlook.office365.com/EWS.AccessAsUser.All`
2. Add the token to headers:
var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); service.setUrl(URI.create("https://outlook.office365.com/ews/exchange.asmx")); service.getHttpHeaders().put("Authorization", "Bearer " + token);
- Sorin332Copper Contributor
prestonsbutler Mikhail295 MichaelDenmark
We have a working app using Basic Authentication and we migrated to Oauth 2 but we receive this error from EWS.
Uncaught SoapFault exception: [a:ErrorInternalServerError] An internal server error occurred. The operation failed.
Our app was implemented long time ago in PHP using php-ews library, so we updated the library to this one which supports Oauth 2.
We generated the token using their api https://login.microsoftonline.com/{{tenant_id}}/oauth2/token and client_credentials flow since there is no user interaction.We use Office 365 Exchange Online permissions with full_access_as_app and https://outlook.office365.com/.default scope to generate the token. We use X-AnchorMailbox header and impersonate soap header as well.
Do you have any clue how to fix it?