ews-java-api
ews-java-api copied to clipboard
401
Hi Team,
On executing the below snippet, i am getting 401 error, could you please suggest .
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1); ExchangeCredentials credentials = new WebCredentials("username", "password","domain");
service.setTraceEnabled(true);
service.setTraceFlags(EnumSet.allOf(TraceFlags.class));
service.setTraceListener(new ITraceListener() {
public void trace(String traceType, String traceMessage) {
System.out.println("Type:" + traceType + " Message:" + traceMessage);
}
});
service.setUrl(new URI("EWS url"));
Caused by: microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The remote server returned an error: (401)Unauthorized
Are you using Office365?
Try to use UPN (emailAddress) in WebCredentials()
.
ExchangeCredentials credentials = new WebCredentials(emailAddress, password);
Thanks for your response. Yes i am using outlook 365. After using the emailaddress, i am getting the below error.
Exception in thread "main" microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. The remote server returned an error: (503)Service Unavailable
What is URL you set?
service.setUrl(new URI("https://outlook.office365.com/EWS/Exchange.asmx"));
yes right
Is your user able to connect by the URL specified above and see content of the page?
Is your user able to connect by the URL specified above and see content of the page?
Hi ... I have the same issue and I don't see the content when I connect to the URL. It just prompts for username and password. Any clue ??
It works from my local but not from the servers.