Skip to content

Instantly share code, notes, and snippets.

@challengee
Last active August 29, 2015 14:02
Show Gist options
  • Save challengee/c4da45c865d32a58b3ff to your computer and use it in GitHub Desktop.
Save challengee/c4da45c865d32a58b3ff to your computer and use it in GitHub Desktop.

Step 1

Create a contact and add an "Instant Messaging" field. Set the protocol to a custom protocol by typing in it (for example: "None").

If you get this contact via the API, you get something like this:

GET /m8/feeds/contacts/default/full/3f9ffe1d8c52ef93?prettyprint=true HTTP/1.1
Host: www.google.com
Gdata-version: 3.0
Content-length: 0
Authorization: Bearer XXXX

HTTP/1.1 200 OK
Gdata-version: 3.1
Content-length: 1462
X-xss-protection: 1; mode=block
Content-location: https://www.google.com/m8/feeds/contacts/default/full/3f9ffe1d8c52ef93?prettyprint=true
X-content-type-options: nosniff
Alternate-protocol: 443:quic
Etag: "R307ezVSLit7I2A9XRZSGE0KQA0."
Expires: Tue, 03 Jun 2014 13:17:20 GMT
Vary: Accept, X-GData-Authorization, GData-Version
X-google-cache-control: remote-fetch
Server: GSE
Last-modified: Tue, 03 Jun 2014 13:06:36 GMT
Via: HTTP/1.1 GWA
Cache-control: private, max-age=0, must-revalidate, no-transform
Date: Tue, 03 Jun 2014 13:17:20 GMT
X-frame-options: SAMEORIGIN
Content-type: application/atom+xml; charset=UTF-8; type=entry
-content-encoding: gzip
<?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' gd:etag='&quot;R307ezVSLit7I2A9XRZSGE0KQA0.&quot;'>
        <id>http://www.google.com/m8/feeds/contacts/mattias%40piesync.com/base/3f9ffe1d8c52ef93</id>
        <updated>2014-06-03T13:06:36.303Z</updated>
        <app:edited xmlns:app='http://www.w3.org/2007/app'>2014-06-03T13:06:36.303Z</app:edited>
        <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/>
        <title>Google Bug</title>
        <link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/mattias%40piesync.com/3f9ffe1d8c52ef93'/>
        <link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/mattias%40piesync.com/full/3f9ffe1d8c52ef93'/>
        <link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/mattias%40piesync.com/full/3f9ffe1d8c52ef93'/>
        <gd:name>
                <gd:fullName>Google Bug</gd:fullName>
                <gd:givenName>Google</gd:givenName>
                <gd:familyName>Bug</gd:familyName>
        </gd:name>
        <gd:im address='test' protocol='None' rel='http://schemas.google.com/g/2005#other'/>
        <gContact:groupMembershipInfo deleted='false' href='http://www.google.com/m8/feeds/groups/mattias%40piesync.com/base/6'/>
</entry>

So the protocol is set to None.

Step 2

Now try to update the same contact via a batch request, where we just update the family name to "Bug update". This is the request and response:

POST /m8/feeds/contacts/default/full/batch HTTP/1.1
Host: www.google.com
Gdata-version: 3.0
Content-length: 1628
Content-type: application/atom+xml
Authorization: Bearer XXX
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
      xmlns:gContact='http://schemas.google.com/contact/2008'
      xmlns:gd='http://schemas.google.com/g/2005'
      xmlns:batch='http://schemas.google.com/gdata/batch'>
  <entry gd:etag='&quot;R307ezVSLit7I2A9XRZSGE0KQA0.&quot;'>
          <id>http://www.google.com/m8/feeds/contacts/mattias%40piesync.com/base/3f9ffe1d8c52ef93</id>
          <updated>2014-06-03T13:06:36.303Z</updated>
          <app:edited xmlns:app='http://www.w3.org/2007/app'>2014-06-03T13:06:36.303Z</app:edited>
          <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/>
          <title>Google Bug</title>
          <link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/mattias%40piesync.com/3f9ffe1d8c52ef93'/>
          <link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/mattias%40piesync.com/full/3f9ffe1d8c52ef93'/>
          <link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/mattias%40piesync.com/full/3f9ffe1d8c52ef93'/>
          <gd:name>
                  <gd:fullName>Google Bug</gd:fullName>
                  <gd:givenName>Google</gd:givenName>
                  <gd:familyName>Bug Update</gd:familyName>
          </gd:name>
          <gd:im address='test' protocol='None' rel='http://schemas.google.com/g/2005#other'/>
          <gContact:groupMembershipInfo deleted='false' href='http://www.google.com/m8/feeds/groups/mattias%40piesync.com/base/6'/>
  </entry>
</feed>

Response:

HTTP/1.1 400 Bad Request
Alternate-protocol: 443:quic
Content-length: 302
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
X-google-cache-control: remote-fetch
-content-encoding: gzip
Server: GSE
Via: HTTP/1.1 GWA
Cache-control: private, max-age=0
Date: Tue, 03 Jun 2014 13:18:55 GMT
X-frame-options: SAMEORIGIN
Content-type: application/vnd.google.gdata.error+xml; charset=UTF-8
Expires: Tue, 03 Jun 2014 13:18:55 GMT
<?xml version="1.0" encoding="UTF-8"?>
<errors xmlns="http://schemas.google.com/g/2005">
 <error>
  <domain>GData</domain>
  <code>invalid</code>
  <internalReason>Invalid value for: Expected a value starting with 'http://schemas.google.com/g/2005#' but got 'None'</internalReason>
 </error>
</errors>

This results in an error, while only information received from the api was sent back. This is definitely not expected behavior.

When issueing a normal update request (no batch), it works as expected:

PUT /m8/feeds/contacts/default/full/3f9ffe1d8c52ef93?prettyprint=true HTTP/1.1
Host: www.google.com
Gdata-version: 3.0
Content-length: 1543
Content-type: application/atom+xml
Authorization: Bearer XXX
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='&quot;R307ezVSLit7I2A9XRZSGE0KQA0.&quot;'>
        <id>http://www.google.com/m8/feeds/contacts/mattias%40piesync.com/base/3f9ffe1d8c52ef93</id>
        <updated>2014-06-03T13:06:36.303Z</updated>
        <app:edited xmlns:app='http://www.w3.org/2007/app'>2014-06-03T13:06:36.303Z</app:edited>
        <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/>
        <title>Google Bug</title>
        <link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/mattias%40piesync.com/3f9ffe1d8c52ef93'/>
        <link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/mattias%40piesync.com/full/3f9ffe1d8c52ef93'/>
        <link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/mattias%40piesync.com/full/3f9ffe1d8c52ef93'/>
        <gd:name>
                <gd:fullName>Google Bug</gd:fullName>
                <gd:givenName>Google</gd:givenName>
                <gd:familyName>Bug Update</gd:familyName>
        </gd:name>
        <gd:im address='test' protocol='None' rel='http://schemas.google.com/g/2005#other'/>
        <gContact:groupMembershipInfo deleted='false' href='http://www.google.com/m8/feeds/groups/mattias%40piesync.com/base/6'/>
</entry>

Response:

HTTP/1.1 200 OK
Gdata-version: 3.1
Content-length: 1469
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Alternate-protocol: 443:quic
Etag: "RHk7fjVSLyt7I2A9XRZSGE0LQAM."
Expires: Tue, 03 Jun 2014 13:22:55 GMT
X-google-cache-control: remote-fetch
Server: GSE
Via: HTTP/1.1 GWA
Cache-control: private, max-age=0
Date: Tue, 03 Jun 2014 13:22:55 GMT
X-frame-options: SAMEORIGIN
Content-type: application/atom+xml; charset=UTF-8; type=entry
-content-encoding: gzip
<?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' gd:etag='&quot;RHk7fjVSLyt7I2A9XRZSGE0LQAM.&quot;'>
        <id>http://www.google.com/m8/feeds/contacts/mattias%40piesync.com/base/3f9ffe1d8c52ef93</id>
        <updated>2014-06-03T13:22:55.706Z</updated>
        <app:edited xmlns:app='http://www.w3.org/2007/app'>2014-06-03T13:22:55.706Z</app:edited>
        <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/>
        <title>Google Bug</title>
        <link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/mattias%40piesync.com/3f9ffe1d8c52ef93'/>
        <link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/mattias%40piesync.com/full/3f9ffe1d8c52ef93'/>
        <link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/mattias%40piesync.com/full/3f9ffe1d8c52ef93'/>
        <gd:name>
                <gd:fullName>Google Bug</gd:fullName>
                <gd:givenName>Google</gd:givenName>
                <gd:familyName>Bug Update</gd:familyName>
        </gd:name>
        <gd:im address='test' protocol='None' rel='http://schemas.google.com/g/2005#other'/>
        <gContact:groupMembershipInfo deleted='false' href='http://www.google.com/m8/feeds/groups/mattias%40piesync.com/base/6'/>
</entry>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment