2011-01-10 19 views
2

更新現有ContactEntry以將GroupMembershipInfo包括在現有ContactGroupEntry中的正確方法是什麼?能夠從ContactEntry中刪除GroupMembershipInfo,但無法添加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 

我能夠成功地檢索聯繫人,並刪除組成員,但添加組成員身份是逃避我,我一直無法找出正確的谷歌搜索找到的示例代碼一個有用的片段

回答

0

GroupEntry被添加到被添加到ContactEntry

的GroupMembership

entry.getGroupMembershipInfos()。add(g);

GroupMembershipInfo g = new GroupMembershipInfo(); 
g.setHref(groupNameId); 
entry.getGroupMembershipInfos().add(g); 
contactsService.update(new URL(entry.getEditLink().getHref()), entry); 
相關問題