3

docsによると、コレクションからアイテムを削除するために 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 ドキュメントからリソースを削除する

私の Apps Script コードは次のとおりです。

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 に答える