OfficeDev / ews-java-api

A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
MIT License
868 stars 559 forks source link

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. An internal server error occurred. The operation failed. #746

Open skenkre opened 3 years ago

skenkre commented 3 years ago

I get this error using EWS java api :

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. An internal server error occurred. The operation failed. at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74) at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:158) at microsoft.exchange.webservices.data.core.ExchangeService.internalFindFolders(ExchangeService.java:377) at microsoft.exchange.webservices.data.core.ExchangeService.findFolders(ExchangeService.java:425) at microsoft.exchange.webservices.data.core.ExchangeService.findFolders(ExchangeService.java:461) at com.neustar.EWSOffice365Reader.main(EWSOffice365Reader.java:189) Caused by: microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: An internal server error occurred. The operation failed. at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.processWebException(ServiceRequestBase.java:548) at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:641) at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:62) ... 5 more

The error is shown at below mentioned line.

FindFoldersResults findResults = service.findFolders(WellKnownFolderName.Inbox, folderview);

The service code is as below :

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); service.setUrl(new URI("https://outlook.office365.com/EWS/Exchange.asmx")); BearerAccessToken bat = new BearerAccessToken(future.get().accessToken()); TokenCredentials credentials = new TokenCredentials(bat.getValue()); service.setImpersonatedUserId(new ImpersonatedUserId(ConnectingIdType.SmtpAddress , MAILBOX)); service.getHttpHeaders().put("X-AnchorMailbox", MAILBOX); service.setCredentials(credentials); service.setTraceEnabled(true);

I get the access token properly but the moment it comes across FindFoldersResults findResults it throws above mentioned exception.

EATONJIANGHAHAHA commented 2 years ago

@skenkre We encountered the same problem. Did all your calls to EWS threw the same exception?

iaavo commented 1 year ago

Just wanted to bump this. I provided a PR to fix this.