能够从 ContactEntry 中删除 GroupMembershipInfo,但无法添加 GroupMembershipInfo

发布于 2024-10-11 11:37:40 字数 646 浏览 7 评论 0原文

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

我正在使用 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 搜索来找到一段有用的示例代码

What is the proper way to update an existing ContactEntry to include GroupMembershipInfo in an existing ContactGroupEntry?

I am using the Java APIs 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

I am able to successfully retrieve contacts and remove group membership, but adding group membership is eluding me, and I have been unable to figure out the right Google search to find a useful piece of sample code

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

任性一次 2024-10-18 11:37:40

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);

GroupEntry is added to the GroupMembership which is added to the ContactEntry

entry.getGroupMembershipInfos().add(g);

GroupMembershipInfo g = new GroupMembershipInfo();
g.setHref(groupNameId);
entry.getGroupMembershipInfos().add(g);
contactsService.update(new URL(entry.getEditLink().getHref()), entry);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文