驱动器 API 文件修补方法失败,并显示“先决条件失败”“conditionNotMet”

ble*_*per 5 google-app-engine google-drive-api

似乎一夜之间 Google Drive API 方法 files().patch( , ).execute() 停止工作并抛出异常。如果您“尝试一下”,通过 Google 的参考页面https://developers.google.com/drive/v2/reference/files/patch也可以观察到这个问题。

异常响应是:

500 Internal Server Error

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  162
content-type:  application/json; charset=UTF-8
date:  Thu, 22 Aug 2013 12:32:06 GMT
expires:  Thu, 22 Aug 2013 12:32:06 GMT
server:  GSE

    {
     "error": {
      "errors": [
       {
        "domain": "global",
        "reason": "conditionNotMet",
        "message": "Precondition Failed",
        "locationType": "header",
        "location": "If-Match"
       }
      ],
      "code": 500,
      "message": "Precondition Failed"
     }
    }
Run Code Online (Sandbox Code Playgroud)

这确实影响了我们的应用程序。

pin*_*yid 1

此处重复获取 500:修补文件夹时先决条件失败。为什么?

我记得一个开发视频中的评论说“使用更新而不是补丁,因为它内部服务器往返次数减少了一次”。我由此推断 Patch 检查 etag,但 Update 不检查。我已更改代码以使用更新代替补丁,此后问题就没有再出现。

一定喜欢针对移动目标进行开发;-)