java - Google Docs Java API 中 ListEntry.update() 上的 com.google.gdata.util.PreconditionFailedException

标签 java google-api

我有一个应用程序可以处理谷歌电子表格的行。有时,当我调用 ListEntry.update() 时,我会收到以下堆栈跟踪信息:

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: com.google.gdata.util.PreconditionFailedException: Precondition Failed
Mismatch: etags = ["E10QemAgYit7ImA-CEFaShYM"], version = [2ag9hk74om621l]
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:614)
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.update(Service.java:1563)
at com.google.gdata.client.Service.update(Service.java:1530)
at com.google.gdata.client.GoogleService.update(GoogleService.java:597)
at com.google.gdata.data.BaseEntry.update(BaseEntry.java:639)
at feedProcessor.ProcessClientFeed.UpdateRow(ProcessClientFeed.java:466)
at feedProcessor.ProcessClientFeed.updateGoogleSpreadsheet(ProcessClientFeed.java:404)
at feedProcessor.ProcessClientFeed.processFeed(ProcessClientFeed.java:318)
at feedProcessor.ProcessClientFeed.main(ProcessClientFeed.java:61)
... 5 more

最佳答案

相关文档如下:

https://developers.google.com/gdata/javadoc/com/google/gdata/data/spreadsheet/ListEntry

https://developers.google.com/gdata/javadoc/com/google/gdata/data/BaseEntry#update()

根据这些文档,update() 函数甚至不能抛出 PreconditionFailedException,因此这些文档在这里基本上没有用。测试该问题表明,当您尝试在 session 中多次调用同一行上的 update() 函数时会抛出此异常。究竟是什么定义了“ session ”仍不清楚,但如果您多次遍历所有行,并在每次迭代中对每一行调用 update(),您将收到此错误。我知道的唯一解决办法是编写您的软件,使每一行 (ListEntry) 只调用一次 update()。

关于java - Google Docs Java API 中 ListEntry.update() 上的 com.google.gdata.util.PreconditionFailedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19006892/

相关文章:

.net - 我的个人硬盘中的 C# Google Drive API 文件列表

java - 如何禁用日志记录调用路径

java - 如何在java swing组件中创建多个框架

java - 替代 Java 8 中的 Thread.stop()?

google-app-engine - Google 开发者控制台中的凭据未加载

android - 无法启动服务 com.android.vending.billing.IMarketBillingService

php - Google Calendar API (v3) - PHP 可以写但不能读?

delphi - 具有自定义 uri 架构的桌面应用程序, token 请求时为 "Missing scheme"

c# - MVC模式: best way to display an array of elements

java - 通过Gson将对象转换为Json时出现OutOfMemory异常