3

我正在尝试使用 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。

有什么解决方案吗,有人可以帮忙吗?

4

0 回答 0