【问题标题】:Google Contacts API "Invalid request." 400 error on name changeGoogle 通讯录 API“无效请求”。更改名称时出现 400 错误
【发布时间】:2019-04-22 19:08:25
【问题描述】:

在尝试仅编辑联系人姓名而不进行任何其他更改(更新时间除外)时,通过 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="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"/>

我见过的最奇怪的事情......不知道从这里去哪里。有什么建议吗?

【问题讨论】:

  • 试试 google people api 比玩 xml 更好
  • @DalmTo people api 和 contacts api 之间有什么大的不同吗?
  • People api = json contacts api Xml 将是最大的区别。至于方法,你应该比较你在联系人中使用的方法,并确保相同的方法在人们中可用。

标签: google-api contacts google-contacts-api


【解决方案1】:

只花了一整天时间想出的解决方案:

仅更改联系人姓名时,需要从您发送给 Google 的 XML 中删除 displayName 属性。

这会成功:

<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" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-04
    • 1970-01-01
    • 2023-02-09
    • 2019-05-10
    相关资源
    最近更新 更多