尝试编辑联系人姓名时没有任何其他更改(除了更新时间),通过Google Contacts API更新联系人失败。
重要说明:当名称更改与电子邮件或电话号码一起发送时,更改成功...仅当单独发送名称更改时才会发生错误。例如,更改联系人姓名并更改电子邮件地址(或电话号码)中的1个字符可使请求成功。
来自Google服务器的响应(http_code 400):“请求无效。”
<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"/>
我见过的最奇怪的事情......不知道从哪里开始。有什么建议?
解决方案,只花了一整天才弄明白:
仅更改联系人姓名时,无需其他任何内容,需要从您发送给Google的XML中删除displayName
属性。
这将成功:
<gd:email rel="http://schemas.google.com/g/2005#work" address="[email protected]" />
这将失败:
<gd:email rel="http://schemas.google.com/g/2005#work" displayName="SameFirst DifferentLast" address="[email protected]" />