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
870 stars 560 forks source link

The request failed. The remote server returned an error: (401)Unauthorized ( Intermittently) #743

Open maxynandy opened 3 years ago

maxynandy commented 3 years ago

Hi ,I am trying to read emails using this ews-java-api every 5 mins using a batch process and it completes in 1 min max as we just read first 10 emails. In a day we can see average 3 to 5 times intermittent error "The request failed. The request failed. The remote server returned an error: (401)Unauthorized".

It occurs when we call below highlighted line: Mailbox mb = new Mailbox(emailAddress); FolderId folder = new FolderId(WellKnownFolderName.Inbox, mb); FindItemsResults result = service.findItems(folder, view);