google-apigoogle-shared-contacts

Conflict 409 error when creating a Google Shared Contact using API


I'm continually getting a HTTP 409 "Conflict" error when attempting to add a new Google Shared Contact using the API.

I've followed the documentation as closely as possible and have defined the new entry as so:

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

I've set up my HTTP request as follows:

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)

In this example CS_FEED_DEFAULT is the shared contact URL and lsOut is my entry as defined above.

After sending this request I get the 409 response and the following response text:

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

Can anyone offer me any advice on this issue?

Thanks.


Solution

  • According to the contacts API documentation, "409 error can be returned when there is a different contact with the same email address. As for now, google contacts API does not allow two different contacts to share an email address".

    Have you been trying to add the same email address twice?