How do I edit a Contact's Group using GContacts?

Unfortunately, the GContact component can't adjust the Group of a contact, but you can use the GData component to do so.

Date Entered: 03/27/2014    Last Updated: 08/19/2014

Our GContacts component is not designed to work with Google groups. That being said, you can see a particular group's specific GroupId by using the GetGroupId configuration setting of the GContacts component. Otherwise, you'll need to construct a custom request using the GData Component. I've included some sample code below to illustrate this process. This code was built using the API information at the following URL:

Create a new group called "Test Group" with the description "This is a test group." //gdata.User = "" //gdata.Password = "yourpassword" gdata.Config("ServiceName=cp"); gdata.EntryElements.Add(new GDataEntryElement()); gdata.EntryElements[0].Name = "title"; gdata.EntryElements[0].Value = "Test Group"; gdata.EntryElements.Add(new GDataEntryElement()); gdata.EntryElements[1].Name = "gd.extendedProperty"; gdata.EntryElements[1].Attributes = "name=\"more info about the group\""; gdata.EntryElements[1].ValueFormat = EntryElementFormats(2); //vfFullXML gdata.EntryElements[1].Value = "This is a test group."; gdata.FeedURL = ""; gdata.CreateEntry();

Finding a contact and editing the group //logging in and querying the groups //gdata.Config(""); //gdata.Config("Password=password"); gdata.Config("ServiceName=cp"); gdata.FeedURL = ""; gdata.QueryFeed(); //index of the group we want indexOfEntry = -1; //empty string for group feed URL to add to contact String groupFeed = ""; //finding the group for (int i = 0; i < gdata.EntryCount; i++) { gdata.EntryIndex = i; if(gdata.GetProperty("title") == "My Contact Group B") { indexOfEntry = i; groupFeed = gdata.GetProperty("id"); } } //getting all the users gdata.FeedURL = ""; //finding the user we want to change gdata.AddQueryParam("q", "Steve Rogers"); gdata.QueryFeed(); //index of contact feed url int indexOfContactFeed = -1; for (int i = 0; i < gdata.EntryElements.Count; i++) { if (gdata.EntryElements[i].Name == "id") indexOfContactFeed = i; //Console.Write(gdata.EntryElements[i].Name + ': '); //Console.WriteLine(gdata.EntryElements[i].Value); } //Google API says to use 'full' not 'base' String editURL = gdata.EntryElements[indexOfContactFeed].Value.Replace("base", "full"); //updating the Gdata object to edit the contact gdata.EntryEditURL = editURL; //adding a new group membership to the contact gdata.EntryElements.Add(new GDataEntryElement()); gdata.EntryElements[gdata.EntryElements.Count - 1].Name = "gContact:groupMembershipInfo"; string attributes = "deleted=\"false\" href=\"" + groupFeed + "\""; gdata.EntryElements[gdata.EntryElements.Count - 1].Attributes = attributes; //updating the entry gdata.UpdateEntry();

We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at