我正在尝试使用ews java api来创建联系人。我尝试使用通过OAuth2工作流程获得的accessToken来验证服务。我收到例外Caused by: javax.xml.stream.XMLStreamException: Local name cannot be null
这是我的代码基于github的例子。
String accessToken =null;
Token token = null;
try
{
token = DatabaseUtils.getaccessTokensAPI(uniqueApiID);
accessToken=token.getAccessToken();
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
TokenCredentials credentials = new TokenCredentials(accessToken);
service.setCredentials(credentials);
service.setUrl(new URI("APP ID URI"));
Contact contact = new Contact(service);
contact.setGivenName("ContactName");
contact.setMiddleName ("mName");
contact.setSurname("sName");
contact.setSubject("Contact Details");
// Specify the company name.
contact.setCompanyName("technolgies");
PhysicalAddressEntry paEntry1 = new PhysicalAddressEntry();
paEntry1.setStreet("12345 Main Street");
paEntry1.setCity("Seattle");
paEntry1.setState("orissa");
paEntry1.setPostalCode("11111");
paEntry1.setCountryOrRegion("INDIA");
contact.getPhysicalAddresses().setPhysicalAddress(PhysicalAddressKey.Home, paEntry1);
contact.save();
}
catch(Exception e)
{
e.printStackTrace();
}
我不确定我是否只能使用访问令牌来验证服务,而不确定使用什么作为参数service.setUrl()App ID URI是否合适?
感谢任何帮助。
答案 0 :(得分:0)
ExchangeService.SetUrl
的目的是设置EWS端点的URL,而不是设置您的应用ID。假设这是Office 365,您应该将其设置为https://outlook.office365.com/ews/exchange.asmx