2

更新现有 ContactEntry 以在现有 ContactGroupEntry 中包含 GroupMembershipInfo 的正确方法是什么?

我正在使用 Java API com.google.gdata.data.contacts ...

// groupNameId was fetched with ContactGroupEntry.getId()
// entry is a known-good ContactEntry
// contactsService is a properly authenticated feed

GroupMembershipInfo g = new GroupMembershipInfo();
g.setHref(groupNameId);
entry.addGroupMembershipInfo(g); 
contactsService.update(new URL(entry.getEditLink().getHref()), entry);
// .... fails with PreconditionFailedException

我能够成功检索联系人并删除组成员身份,但我无法添加组成员身份,而且我无法找出正确的 Google 搜索来找到有用的示例代码

4

1 回答 1

0

GroupEntry 添加到 GroupMembership 中,该 GroupMembership 添加到 ContactEntry

entry.getGroupMembershipInfos().add(g);

GroupMembershipInfo g = new GroupMembershipInfo();
g.setHref(groupNameId);
entry.getGroupMembershipInfos().add(g);
contactsService.update(new URL(entry.getEditLink().getHref()), entry);
于 2011-01-11T17:58:44.170 回答