0
votes

Updating a contact via the Google Contacts API fails when trying to edit a contacts name only without any other changes (besides updated time).

Important note: When the name change is sent along with an email or phone number change it succeeds... only when the name change is sent alone does an error occur. For example changing the contact name and changing 1 character in the email address (or phone number) makes the request successful.

Response from Google Server (http_code 400): "Invalid request."

<entry
xmlns="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005" gd:etag="*">
<id>http://www.google.com/m8/feeds/contacts/example%40gmail.com/base/realcontactidhere</id>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
<title>SameFirst DifferentLast</title>
<updated>2019-04-22T18:55:59+00:00</updated>
<gd:name>
    <gd:givenName>SameFirst</gd:givenName>
    <gd:familyName>DifferentLast</gd:familyName>
    <gd:fullName>SameFirst DifferentLast</gd:fullName>
</gd:name>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#mobile">+1 555 555 5555</gd:phoneNumber>
<gd:email rel="http://schemas.google.com/g/2005#work" displayName="SameFirst DifferentLast" address="[email protected]" />
<link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/example%40gmail.com/realcontactidhere?v=3.0"/>
<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/example%40gmail.com/full/realcontactidhere?v=3.0"/>
<link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/example%40gmail.com/full/realcontactidhere?v=3.0"/>

Strangest thing I have seen... not sure where to go from here. Any suggestions?

1
Try the google people api its better than playing with xmlDaImTo
@DalmTo any big differences between the people api and the contacts api?Milk Man
People api = json contacts api Xml would be the biggest difference. As for the methods you should compare which methods you are using in contacts and make sure that the same are available in people.DaImTo

1 Answers

2
votes

Solution that only took all day to figure out:

When changing a contact name only, and nothing else, the displayName property needs to be removed from the XML you are sending to Google.

This will succeed:

<gd:email rel="http://schemas.google.com/g/2005#work" address="[email protected]" />

This will fail:

<gd:email rel="http://schemas.google.com/g/2005#work" displayName="SameFirst DifferentLast" address="[email protected]" />