【问题标题】:able to remove GroupMembershipInfo from ContactEntry, but unable to add GroupMembershipInfo能够从 ContactEntry 中删除 GroupMembershipInfo,但无法添加 GroupMembershipInfo
【发布时间】:2011-06-06 20:53:57
【问题描述】:

更新现有 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 搜索找到有用的示例代码

【问题讨论】:

    标签: java gdata-api google-data-api


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-01-04
      • 2020-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多