2014-12-19 94 views
0

好吧,事情開始爲我工作。但是,現在我試圖更新聯繫人,並且正在獲取「缺少資源版本ID」消息。步驟:谷歌聯繫人錯誤「缺少資源版本ID」

1)檢索通過API的接觸 - 成功 2更新值在接觸 3)寫出的XML文件與新的「入門」) - XML驗證 4)嘗試做PUT和我得到錯誤。

put命令我使用的是:

curl -s --request PUT \ 
     --header If-Match: * \ 
     --header "Content-Type: application/atom+xml" \ 
     --header "Depth: 0" \ 
     --header "Authorization: Bearer <auth code> \ 
     --data-binary @/tmp/GooglePut0AGQzE \ 
https://www.google.com/m8/feeds/contacts/default/full/4375e4498ef0b274 

XML是:

<entry xmlns="http://www.w3.org/2005/Atom" 
     xmlns:batch="http://schemas.google.com/gdata/batch" 
     xmlns:gContact="http://schemas.google.com/contact/2008" 
     xmlns:gd="http://schemas.google.com/g/2005"> 
    <category scheme="http://schemas.google.com/g/2005#kind" 
       term="http://schemas.google.com/contact/2008#contact" /> 
    <id>http://www.google.com/m8/feeds/contacts/default/base/4375e4498ef0b274</id> 
    <gContact:externalId label="enduser_acnt" rel="http://schemas.google.com/g/2005#customer" value="6006533" /> 
    <gd:name><gd:givenName>Dwayne</gd:givenName><gd:familyName>Johnson</gd:familyName></gd:name> 
    <title type="text">Andy Wallace</title> 
    <content type="text">Hello</content> 
    <gd:organization rel="http://schemas.google.com/g/2005#other"> 
     <gd:orgName>iHOUSEweb, Inc</gd:orgName> 
     <gd:orgTitle>Engineer</gd:orgTitle> 
    </gd:organization> 
    <gd:structuredPostalAddress rel="http://schemas.google.com/g/2005#home" primary="true"> 
     <gd:street>100 Smell St</gd:street> 
     <gd:city>Smellville</gd:city> 
     <gd:region>CA</gd:region> 
    </gd:structuredPostalAddress> 
    <gd:email rel="http://schemas.google.com/g/2005#work" address="[email protected]" primary="true" /> 
    <gd:phoneNumber rel="http://schemas.google.com/g/2005#home" primary="true" >333-444-3333</gd:phoneNumber> 
    <gd:phoneNumber rel="http://schemas.google.com/g/2005#work" >222-333-4444</gd:phoneNumber> 
</entry> 

什麼錯誤意味着什麼建議?我試圖剝去數據的各個位,指定/不指定「If-Match:*」標題,但似乎沒有任何改變。

感謝, 安迪

回答

1

添加如果匹配報頭字段,並確保您正在使用最新版本運行你的API。

https://developers.google.com/apps-script/

+0

謝謝,試過如果匹配頭 - 注意我上面的curl命令,還是我這樣做是否有誤?我沒有使用API​​,只是用可執行的curl命令直接驅動Google API – 2014-12-19 17:10:44

1

好了,發現我的問題。我錯誤地使用了「If-Match」標題。衛生署...

curl -s --request PUT \ 
     --header "If-Match: *" \ 
     --header "Content-Type: application/atom+xml" \ 
     --header "Depth: 0" \ 
     --header "Authorization: Bearer <auth key>" \ 
     --data-binary @/tmp/GooglePutwAdE69 \ 
     https://www.google.com/m8/feeds/contacts/default/full/4375e4498ef0b274 

感謝dumbgamergirl,指着我的大腦在正確的方向