使用API创建Google共享联系人时发生冲突409错误



当我尝试使用API添加新的Google共享联系人时,不断收到HTTP 409"冲突"错误。

我已经尽可能仔细地遵循了文档,并将新条目定义为:

<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>
  <atom:category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact' />
  <gd:name>
    <gd:givenName>Test</gd:givenName>
    <gd:familyName>Testerson</gd:familyName>
    <gd:fullName>Test Testerson</gd:fullName>
  </gd:name>
  <atom:content type='text'></atom:content>
  <gd:email rel='http://schemas.google.com/g/2005#work' primary='true' address='test.testerson@sample.com.au' displayName='' />
  <gd:email rel='http://schemas.google.com/g/2005#home' address='' />
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>(07) 33331111</gd:phoneNumber>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'>0411223344</gd:phoneNumber>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#fax'>(07) 33331122</gd:phoneNumber>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#home'></gd:phoneNumber>
  <gd:im address='' protocol='http://schemas.google.com/g/2005#GOOGLE_TALK' primary='true' rel='http://schemas.google.com/g/2005#home' />
  <gd:structuredPostalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>
    <gd:city>Abbey</gd:city>
    <gd:street>PO Box 4561</gd:street>
    <gd:region>WA</gd:region>
    <gd:postcode>6280</gd:postcode>
    <gd:country>Australia</gd:country>
    <gd:formattedAddress>PO Box 4561, Abbey, WA, 6280, Australia</gd:formattedAddress>
  </gd:structuredPostalAddress>
  <gd:structuredPostalAddress rel='http://schemas.google.com/g/2005#other'>
    <gd:city>Abbey</gd:city>
    <gd:street>47 Example Avenue</gd:street>
    <gd:region>WA</gd:region>
    <gd:postcode>6280</gd:postcode>
    <gd:country>Australia</gd:country>
    <gd:formattedAddress>47 Example Avenue, Abbey, WA, 6280, Australia</gd:formattedAddress>
  </gd:structuredPostalAddress>
  <gd:organization rel='http://schemas.google.com/g/2005#other'>
    <gd:orgTitle>Guinea Pig</gd:orgTitle>
    <gd:orgName>Test Org</gd:orgName>
  </gd:organization>
</atom:entry>

我已经将我的HTTP请求设置如下:

lsToken = GetAuthToken()
Set lobjHttp = CreateObject("MSXML2.XMLHTTP")
Call lobjHttp.Open("POST", CS_FEED_DEFAULT, False, "", "")
Call lobjHttp.setRequestHeader("Authorization", "GoogleLogin auth=" + lsToken)
Call lobjHttp.setRequestHeader("Content-type", "application/atom+xml")
Call lobjHttp.Send(lsOut)

在本例中,CS_FEED_DEFAULT是共享联系人URL,lsOut是我的条目,如上所述。

发送此请求后,我得到409响应和以下响应文本:

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005'>
  <id>http://www.google.com/m8/feeds/contacts/test.com.au/base/47e904e10dd27dd2</id>
  <updated>2014-09-17T02:08:39.761Z</updated>
  <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/>
  <title type='text'></title>
  <content type='text'></content>
  <link rel='http://schemas.google.com/contacts/2008/rel#edit-photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/test.com.au/47e904e10dd27dd2/1B2M2Y8AsgTpgAmY7PhCfg'/>
  <link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/test.com.au/full/47e904e10dd27dd2'/>
  <link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/test.com.au/full/47e904e10dd27dd2/1410919719761001'/>
  <gd:email rel='http://schemas.google.com/g/2005#work' address='test.testerson@sample.com.au' primary='true'/>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>(07) 33331111</gd:phoneNumber>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'>0411223344</gd:phoneNumber>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#work_fax'>(07) 33331122</gd:phoneNumber>
</entry>

有人能就这个问题给我什么建议吗?

谢谢。

根据联系人API文档,"当有不同的联系人使用相同的电子邮件地址时,会返回409错误。目前,google联系人API不允许两个不同的联系人共享一个电子邮件地址"。

你有没有两次尝试添加同一个电子邮件地址?

我遇到了同样的错误,因为我忘记在GCP上启动以前停止的SQL实例。

最新更新