RequestSettings rs = new RequestSettings("test", Session["username"].ToString(), Session["pass"].ToString());
Contact newEntry = new Contact();
newEntry.Name = new Name()
{
FullName = "Elizabeth Bennet",
GivenName = "Elizabeth",
FamilyName = "Bennet",
};
newEntry.Content = "Notes";
// Set the contact's e-mail addresses.
newEntry.Emails.Add(new EMail()
{
Primary = true,
Rel = ContactsRelationships.IsHome,
});
newEntry.Emails.Add(new EMail()
{
Rel = ContactsRelationships.IsWork,
});
// Set the contact's phone numbers.
newEntry.Phonenumbers.Add(new PhoneNumber()
{
Primary = true,
Rel = ContactsRelationships.IsWork,
});
newEntry.Phonenumbers.Add(new PhoneNumber()
{
Rel = ContactsRelationships.IsHome,
});
// Set the contact's postal address.
newEntry.PostalAddresses.Add(new StructuredPostalAddress()
{
Rel = ContactsRelationships.IsWork,
Primary = true,
Street = "1600 Amphitheatre Pkwy",
City ="Mountain View",
Region = "CA",
Postcode = "94043",
Country = "United States",
FormattedAddress = "1600 Amphitheatre Pkwy Mountain View",
});
// Insert the contact.
Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
Contact createdEntry = cr.Insert(feedUri, newEntry);
Contact contact = cr.Retrieve<Contact>(contactURL);
contact.Name.FullName = "New Name";
contact.Name.GivenName = "New";
contact.Name.FamilyName = "Name";
try
{
Contact updatedContact = cr.Update(contact);
}
catch (GDataVersionConflictException e)
{
// Etags mismatch: handle the exception.
}
Delete contact
Contact contact = cr.Retrieve<Contact>(contactURL);
try
{
cr.Delete(contact);
}
catch (GDataVersionConflictException e)
{
// Etags mismatch: handle the exception.
}
for shared contact pass domain name in uri instead of default.
Hope this works