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 559 forks source link

office 365 Exchange error? #551

Open kervin521 opened 8 years ago

kervin521 commented 8 years ago

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids. at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278) at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267) at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165) at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:985) at microsoft.exchange.webservices.data.core.ExchangeService.findAppointments(ExchangeService.java:1264) at microsoft.exchange.webservices.data.core.ExchangeService.findAppointments(ExchangeService.java:1285)

code follow : url = "https://outlook.office365.com/EWS/Exchange.asmx"; account = "xxxxxx@waferxa.onmicrosoft.com"; password = "xxxxxxx"; calendarId= "greatwall@waferxa.onmicrosoft.com";

ExchangeCredentials credentials = new WebCredentials(account, password); ExchangeService service = new ExchangeService(); service.setCredentials(credentials); service.setTraceEnabled(true); service.setUrl(new URI(url));//手动 service.setPreAuthenticate(true); service.setTimeout(10_60_1000); if(!StringUtils.isBlank(email)){ service.setImpersonatedUserId(new ImpersonatedUserId(ConnectingIdType.SmtpAddress, calendarId)); }

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date startDate = formatter.parse("2014-07-15 00:00:00"); Date endDate = formatter.parse("2016-07-15 00:00:00"); CalendarView view = new CalendarView(startDate, endDate); FindItemsResults appointments = service.findAppointments(WellKnownFolderName.Calendar, view);

kervin521 commented 8 years ago

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: No mailbox with such guid. at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278) at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267) at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165) at microsoft.exchange.webservices.data.core.ExchangeService.internalBindToItems(ExchangeService.java:1343) at microsoft.exchange.webservices.data.core.ExchangeService.bindToItem(ExchangeService.java:1378) at microsoft.exchange.webservices.data.core.ExchangeService.bindToItem(ExchangeService.java:1395) at microsoft.exchange.webservices.data.core.service.item.Appointment.bind(Appointment.java:118) at microsoft.exchange.webservices.data.core.service.item.Appointment.bind(Appointment.java:133)

code when calendarId= "greatwall@waferxa.onmicrosoft.com";

Genzo84 commented 7 years ago

Hi All, i've the same problem. It's strange beacuse if i try to create an appointment, it works without problem. When i try to read the appointment...it show me the same errore above us :/

Any suggestions?

Tnx