仅尝试编辑联系人姓名而不进行任何其他更改(更新时间除外)时,通过Google Contacts API更新联系人失败。
重要说明:当将名称更改与电子邮件或电话号码更改一起发送时,它会成功...仅在单独发送名称更改时才会发生错误。例如,更改联系人姓名并在电子邮件地址(或电话号码)中更改1个字符会使请求成功。
来自Google Server的响应(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="SameFirstDifferentLast@example.com" />
<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"/>
我所见过的最奇怪的事情...不确定从这里去哪里。有什么建议吗?
答案 0 :(得分:0)
只花一整天的解决方案来找出:
仅更改联系人姓名时,displayName
属性需要从发送给Google的XML中删除。
这将成功:
<gd:email rel="http://schemas.google.com/g/2005#work" address="SameFirstDifferentLast@example.com" />
这将失败:
<gd:email rel="http://schemas.google.com/g/2005#work" displayName="SameFirst DifferentLast" address="SameFirstDifferentLast@example.com" />