Python和Gdata:向组添加联系人不起作用

时间:2012-07-26 09:40:41

标签: python contacts gdata-api

我正在尝试通过python使用联系人api,以便为Gmail中的群组添加联系人。 这是我的小组检索this

Atom Id: http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6d1fccc00a474e6c
Group Name: Newsletter
Last Updated: 2012-04-17T14:04:51.565Z
Extended Properties: Self
Link: https://www.google.com/m8/feeds/groups/user%40gmail.com/full/6d1fccc00a474e6c
Edit Link: https://www.google.com/m8/feeds/groups/user%40gmail.com/full/6d1fccc00a474e6c
ETag: "QHs9fTVSLit7I2A9WhVXFkoLQw0."

所以我正在尝试使用这段代码来支持changing group membership

def add_group_membership(gd_client, contact_url, group_atom_id):
  contact = gd_client.GetContact(contact_url)
  contact.group_membership_info.append(gdata.contacts.data.GroupMembershipInfo(href=group_atom_id))
  try:
    updated_contact = gd_client.Update(contact)
    return updated_contact
  except gdata.client.RequestError, e:
    if e.status == 412:
      # Etags mismatch: handle the exception.
      pass
  return None

add_group_membership(gd_client, contact_url, 'http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6d1fccc00a474e6c')

respons

gdata.client.RequestError: Server responded with: 404, Group not found.

我的联系人= gd_client.GetContact(contact_url)是对的

<ns0:entry xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:ns1="http://schemas.google.com/g/2005" xmlns:ns2="http://www.w3.org/2007/app" ns1:etag="&quot;Rn04fTVSLyt7I2A9WhJQEkQKRwI.&quot;">[...]<ns2:edited>2012-07-26T08:07:47.335Z</ns2:edited></ns0:entry>

怎么了?

0 个答案:

没有答案