2012-04-11 54 views
2

刪除資源按照docs解決了ETag錯誤,一條if-match ETAG不需要從集合中刪除一個項目,但我發現了以下錯誤:如何從收集與谷歌Apps腳本

"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標籤?我試着堅持一個「如果 - 匹配:」 *「」在我的選擇,以防萬一,但沒有成功。

這是與此相關的Python客戶端庫的錯誤? DeleteResource from Google Docs with Python

我的Google 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", 
    }; 
} 
+0

你把IF-匹配:在頭? – 2012-04-11 13:52:32

回答

1

的選項正確的語法是:

function buildDeleteOptions_() { 

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