0

尝试使用 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>

任何人都可以就这个问题给我任何建议吗?

谢谢。

4

2 回答 2

0

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

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

于 2014-09-17T15:14:19.450 回答
0

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

于 2021-03-25T07:50:49.287 回答