更新现有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搜索来查找有用的示例代码
答案 0 :(得分:0)
GroupEntry被添加到GroupMembership,并添加到ContactEntry
<强> entry.getGroupMembershipInfos()添加(G); 强>
GroupMembershipInfo g = new GroupMembershipInfo();
g.setHref(groupNameId);
entry.getGroupMembershipInfos().add(g);
contactsService.update(new URL(entry.getEditLink().getHref()), entry);