Hi Kevin,

I recommend you to check the following example:
http://code.google.com/apis/contacts/docs/2.0/developers_guide_java.html#RetrievingGroup

You need get the groups feed for the contact and search for the Name/
SystemName "Contacts" on the Group Entries. Then, for the Entry
matching the name you need to use ID groupEntry.getId()

The ID will look like: 
http://www.google.com/m8/feeds/groups/julian%40juliantoledo.com/base/6

This ID is what you use on the groupMembershipInfo object to set the
Href.

For exmaple:

GroupMembershipInfo groupMembershipInfo = new GroupMembershipInfo();
groupMembershipInfo.setHref(getGroupUrlByName(contactsService,
"contacts"));
contactEntry.addGroupMembershipInfo(groupMembershipInfo);

public static String getGroupUrlByName(ContactsService myService,
            String groupName) throws ServiceException, IOException {
        // Request the feed
        URL feedUrl = new URL(
                "http://www.google.com/m8/feeds/groups/default/full";);
        ContactGroupFeed resultFeed = myService.getFeed(feedUrl,
                ContactGroupFeed.class);
        for (int i = 0; i < resultFeed.getEntries().size(); i++) {
            ContactGroupEntry groupEntry = resultFeed.getEntries().get
(i);
            if (groupEntry.hasSystemGroup()) {
                if (groupEntry.getSystemGroup().getId().equals
(groupName)) {
                    return groupEntry.getId();
                }
            } else {
                if (groupEntry.getTitle().getPlainText().equals
(groupName)) {
                    return groupEntry.getId();
                }
            }
        }
        return null;
    }

Important: My Contacts is actually only "Contacts" on the feed.

Cheers,
Julian

On Jan 12, 5:25 pm, Kevin <[email protected]> wrote:
> Hi,
> I'm using the Java API and converting from GData v1 to v2, and I am
> having trouble seeing how to make a newly added contact appear in the
> My Contacts (system) group.
>
> The migration guide says "In version 2, if you want to place a new
> contact in the My Contacts group, you must do so explicitly, by adding
> an appropriate <gContact:groupMembershipInfo> element to the
> contact."   However, as far as I can tell you cannot use
> ContactEntry.addGroupMembershipInfo to specify a system group like "My
> Contacts", it only works for user-created groups.
>
> I think what I need is to get a <gContact:systemGroup id="Contacts"/>
> element into the XML, but I don't see any ContactEntry class method
> call that would cause that to happen.
>
> Any suggestions?  Thanks.
>
> ---
>      Kevin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Contacts API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to