0

I have written a script to create a shared contact in my G-Suite domain. I have done the OAuth work, and am able to create a contact.

However, when I have created the contact, it does not have all the data I submitted. For example, it does not have name data or title information.

I have tried using the example Google has here: https://developers.google.com/admin-sdk/domain-shared-contacts/#Creating

This is exactly what I am posting:

<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>Elizabeth</gd:givenName>
        <gd:familyName>Bennet</gd:familyName>
        <gd:fullName>Elizabeth Bennet</gd:fullName>
    </gd:name>
    <atom:content type='text'>Notes</atom:content>
    <gd:email rel='http://schemas.google.com/g/2005#work' primary='true' address='liz@gmail.com' displayName='E. Bennet' />
    <gd:email rel='http://schemas.google.com/g/2005#home' address='liz@example.org' />
    <gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>(206)555-1212</gd:phoneNumber>
    <gd:phoneNumber rel='http://schemas.google.com/g/2005#home'>(206)555-1213</gd:phoneNumber>
    <gd:im address='liz@gmail.com' 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>Mountain View</gd:city>
        <gd:street>1600 Amphitheatre Pkwy</gd:street>
        <gd:region>CA</gd:region>
        <gd:postcode>94043</gd:postcode>
        <gd:country>United States</gd:country>
        <gd:formattedAddress>1600 Amphitheatre Pkwy Mountain View</gd:formattedAddress>
    </gd:structuredPostalAddress>
</atom:entry>

It creates the contact, but is missing the names, title, etc.

This is what is returned by the post:

<?xml version='1.0' encoding='UTF-8' ?>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005' xmlns:gContact='http://schemas.google.com/contact/2008'>
    <id>http://www.google.com/m8/feeds/contacts/compcc.com/base/36b40df989628b57</id>
    <updated>2017-01-17T15:42:32.736Z</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'>Notes</content>
    <link rel='http://schemas.google.com/contacts/2008/rel#edit-photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/compcc.com/36b40df989628b57/1B2M2Y8AsgTpgAmY7PhCfg' />
    <link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/compcc.com/full/36b40df989628b57' />
    <link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/compcc.com/full/36b40df989628b57/1484667752736001' />
    <gd:email rel='http://schemas.google.com/g/2005#work' address='liz@gmail.com' primary='true' />
    <gd:email rel='http://schemas.google.com/g/2005#home' address='liz@example.org' />
    <gd:im address='liz@gmail.com' primary='true' protocol='http://schemas.google.com/g/2005#GOOGLE_TALK' rel='http://schemas.google.com/g/2005#home' />
    <gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>(206)555-1212</gd:phoneNumber>
    <gd:phoneNumber rel='http://schemas.google.com/g/2005#home'>(206)555-1213</gd:phoneNumber>
</entry>"

Does anyone know what might cause this?

Thank you.

Dave H
  • 23
  • 2
  • Have you tried retrieving it using [Retrieving a single shared contact](https://developers.google.com/admin-sdk/domain-shared-contacts/#retrieving_single_contact) if this behavior still occur? – Mr.Rebot Jan 18 '17 at 16:02
  • @Mr.Rebot - yes, it does. I ended up opening a ticket with Google about this, and they gave me a solution. I'll post that shortly. – Dave H Jan 19 '17 at 16:55

1 Answers1

0

After opening a ticket with Google, they gave me the following guidance. Upon implementing the new sample XML, I was able to create a new shared contact with a title. That met my needs.

Here is what I received:

In regard to the issue you are experiencing I was able to test and replicate the behavior that you are encountering. Whenever I follow the example the Shared Contact is created but part of the contact information is not complete. I will proceed to report this immediately in order to update the Article that you are referring.

After investigating and running additional tests, I was able to make the API work as expected and I was able to add a Domain Shared Contact with most of the details. I noticed that the Domain Shared Contacts API uses Google Data APIs to push the information to your domain. I was able to find an official example from the Google Data APIs and it seems to work as expected. You can check the example that I am referring here https://developers.google.com/gdata/docs/2.0/elements#examples

Below I am including the example that I used as a reference (Note that I removed the "organization" part from the example provided on the link above):

<entry xmlns='http://www.w3.org/2005/Atom' 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'/>
  <title>Eliza Benne</title>
  <content>My good friend, Liz.  A little quick to judge sometimes, but nice girl.</content>
  <gd:email rel='http://schemas.google.com/g/2005#work' primary='true' address='lizi@gmail.com'/>
  <gd:email rel='http://schemas.google.com/g/2005#home' address='lizi@example.org'/>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>
    (206)555-1212
  </gd:phoneNumber>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#home'>
    (206)555-1213
  </gd:phoneNumber>
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'>
    (206) 555-1212
  </gd:phoneNumber>
  <gd:im rel='http://schemas.google.com/g/2005#home'
      protocol='http://schemas.google.com/g/2005#GOOGLE_TALK'
      address='lizi@gmail.com'/>
  <gd:postalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>
    1600 Amphitheatre Pkwy
    Mountain View, CA 94043
  </gd:postalAddress>
  <gd:postalAddress rel='http://schemas.google.com/g/2005#home'>
    800 Main Street
    Mountain View, CA 94041
  </gd:postalAddress>
</entry>

You should be able to use the above example and add external contacts to your Shared Contacts directory. I will be more than happy to over the steps with you to test this and make sure that the API is working as expected. Note: Please make sure you are using GData-Version: 3.0.

Dave H
  • 23
  • 2