ews-java-api icon indicating copy to clipboard operation
ews-java-api copied to clipboard

401

Open subhashiniv opened this issue 5 years ago • 7 comments

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

subhashiniv avatar May 07 '19 12:05 subhashiniv

Are you using Office365? Try to use UPN (emailAddress) in WebCredentials().

ExchangeCredentials credentials = new WebCredentials(emailAddress, password);

pkropachev avatar May 07 '19 20:05 pkropachev

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

subhashiniv avatar May 08 '19 11:05 subhashiniv

What is URL you set?

service.setUrl(new URI("https://outlook.office365.com/EWS/Exchange.asmx"));

pkropachev avatar May 08 '19 14:05 pkropachev

yes right

subhashiniv avatar May 09 '19 07:05 subhashiniv

Is your user able to connect by the URL specified above and see content of the page?

pkropachev avatar May 09 '19 10:05 pkropachev

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 ??

srilakshmiG avatar Sep 25 '20 20:09 srilakshmiG

It works from my local but not from the servers.

srilakshmiG avatar Sep 25 '20 20:09 srilakshmiG