创建Google群组联系人

时间:2016-03-11 05:32:10

标签: google-api google-contacts

我正在尝试使用Google通讯录v3创建群组联系人。

按照示例并在OAuth 2.0 Playground中进行测试,这是我的示例代码:

POST /m8/feeds/groups/default/full/ HTTP/1.1
Host: www.google.com
Gdata-version: 3.0
Content-length: 355
Content-type: application/atom+xml
Authorization: Bearer #{auth_code_goes_in_here}#
<atom:entry xmlns:gd="http://schemas.google.com/g/2005">
  <atom:category scheme="http://schemas.google.com/g/2005#kind"
    term="http://schemas.google.com/contact/2008#group"/>
  <atom:title type="text">Salsa group</atom:title>
  <gd:extendedProperty name="more info about the group">
    <info>Nice people.</info>
  </gd:extendedProperty>
</atom:entry>

但是,我在响应中不断收到400错误:

HTTP/1.1 400 Bad Request
Alternate-protocol: 443:quic,p=1
Content-length: 236
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Transfer-encoding: chunked
Expires: Fri, 11 Mar 2016 05:18:06 GMT
Vary: Origin, X-Origin
Server: GSE
-content-encoding: gzip
Cache-control: private, max-age=0
Date: Fri, 11 Mar 2016 05:18:06 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="31,30,29,28,27,26,25"
Content-type: application/vnd.google.gdata.error+xml; charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?>
<errors xmlns="http://schemas.google.com/g/2005">
 <error>
  <domain>GData</domain>
  <code>invalid</code>
  <internalReason>Entry does not have any fields set</internalReason>
 </error>
</errors>

我在这里做错了什么想法?

除此之外,我还希望在Google上创建联系人,并附上特定的群组。这可以通过“创建联系人”方法实现吗?我似乎找不到一个可以直接指定组的示例。

感谢您的任何建议。

此致 乐华

1 个答案:

答案 0 :(得分:2)

经过一些痛苦的研究后,我通过更改数据来找到解决方案:

<atom:entry xmlns:gd="http://schemas.google.com/g/2005">
to
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
相关问题