使用API​​创建Google共享联系人时出现Conflict 409错误

时间:2014-09-17 04:11:56

标签: google-api google-shared-contacts

我不断获得HTTP 409"冲突"尝试使用API​​添加新的Google共享联系人时出错。

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

<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>

有人可以就此问题向我提出任何建议吗?

感谢。

2 个答案:

答案 0 :(得分:0)

根据contacts API documentation,“如果与同一电子邮件地址有不同的联系人,则可能会返回409错误。目前,Google联系人API不允许两个不同的联系人共享电子邮件地址”。

您是否尝试过两次添加相同的电子邮件地址?

答案 1 :(得分:0)

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