Google Contacts API - java - 抛出ServiceException的Batch(Create)操作 - 内部服务器错误

时间:2014-04-25 07:59:42

标签: google-api-java-client google-shared-contacts

我正在尝试使用Contacts API(java)使用批处理操作更新/删除联系人或组。

代码:

ContactsService contactService;
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(key);
oauthParameters.setOAuthConsumerSecret(secret);
contactService = new ContactsService(appname);
contactService.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());
ContactFeed feed = new ContactFeed();
ContactEntry contact = new ContactEntry();
contact.setId(atomId.replace("/base/", Matcher.quoteReplacement("/thin/")));
BatchUtils.setBatchId(contact, seqId);
BatchUtils.setBatchOperationType(contact, BatchOperationType.DELETE);
feed.getEntries().add(contact);
if (hasDeleteOperaion) {
  contactsService.setHeader("If-Match", "*");
}
feed = contactsService.batch(feedUrl, feed);
if (hasDeleteOperaion) {
  contactsService.setHeader("If-Match", null);
}

执行上述代码时,获得以下异常:

com.google.gdata.util.ServiceException: Internal Server Error
Internal Error
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:632)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.batch(Service.java:1454)
at com.google.gdata.client.GoogleService.batch(GoogleService.java:770)

我最近从上周开始这样做,我还没有为MarketPlace应用程序实现OAUTH 2.0。

对此有任何解决方案,有人可以帮忙吗?

0 个答案:

没有答案