3

根据文档,从集合中删除项目不需要 If-Match eTag,但我收到以下错误:

"Request failed for returned code 403. Server response:
<errors xmlns='http://schemas.google.com/g/2005'>
  <error>
    <domain>GData</domain>
    <code>matchHeaderRequired</code>
    <location type='header'>If-Match|If-None-Match</location>
    <internalReason>If-Match or If-None-Match header or entry etag attribute required</internalReason>
  </error>
</errors>"

我错过了什么?如果我确实希望丢弃资源,我将如何以及在哪里指定 If-Match 标记?为了以防万一,我尝试在选项中添加“If-Match:”*”,但没有成功。

这与此 Python 客户端库错误有关吗?使用 Python 从 Google Docs 中删除资源

我的 Apps 脚本代码如下:

function deleteResourceFromCollection_(originCollectionId,resourceId) {
  var options = buildDeleteOptions_();

  var result = UrlFetchApp.fetch(DOC_API_URL+ACTIVE_USER+"/private/full/"+originCollectionId+"/contents/"+resourceId, options); 
}

//////////////////////////////////////////////
// Build URLFetchApp Delete Options
//////////////////////////////////////////////
function buildDeleteOptions_() {

  return {
    method : "delete",
    headers : {"GData-Version": "3.0"},
    oAuthServiceName: "google",
    oAuthUseToken: "always",
    };
}
4

1 回答 1

2

选项的正确语法是:

function buildDeleteOptions_() {

  return {
    method : "delete",
    headers : {"GData-Version": "3.0", "If-Match":"*"},
    oAuthServiceName: "google",
    oAuthUseToken: "always",
    };
}
于 2012-04-11T18:03:59.700 回答