首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Google Contacts API "Invalid request.“400更改名称时出错

Google Contacts API "Invalid request.“400更改名称时出错
EN

Stack Overflow用户
提问于 2019-04-23 03:08:26
回答 1查看 309关注 0票数 0

如果仅尝试编辑联系人姓名而不做任何其他更改(更新时间除外),则无法通过Google Contacts API更新联系人。

重要说明:当名称更改与电子邮件或电话号码更改一起发送时,它将成功...只有在单独发送名称更改时,才会发生错误。例如,更改联系人姓名和更改电子邮件地址(或电话号码)中的1个字符将使请求成功。

来自Google Server (http_code 400)的

响应:“无效请求。”

代码语言:javascript
复制
<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"/>

我见过最奇怪的事情..。不知道下一步该怎么走。有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2019-04-23 03:18:51

只花了一整天就能弄清楚的解决方案:

如果只更改联系人姓名,而不更改其他内容,则需要从要发送给Google的XML中删除displayName属性。

这将会成功:

代码语言:javascript
复制
<gd:email rel="http://schemas.google.com/g/2005#work" address="SameFirstDifferentLast@example.com" />

这将失败:

代码语言:javascript
复制
<gd:email rel="http://schemas.google.com/g/2005#work" displayName="SameFirst DifferentLast" address="SameFirstDifferentLast@example.com" />
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55799755

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档