I am working in asp.net C# below is code

pass user name and password in request settings.for shared contact pass 
admin user name and password.

retrieve contacts
 RequestSettings rs = new RequestSettings("test", 
Session["username"].ToString(), Session["pass"].ToString());
        ContactsRequest cr = new ContactsRequest(rs);       
        Uri uri = new 
Uri("https://www.google.com/m8/feeds/contacts/default/full";);
        ContactsQuery query = new ContactsQuery(uri.ToString());
        Feed<Contact> f = cr.Get<Contact>(query);  

Insert contacts

 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,
        Address = "[email protected]"
      });
  newEntry.Emails.Add(new EMail()
      {
        Rel = ContactsRelationships.IsWork,
        Address = "[email protected]"
      });
  // Set the contact's phone numbers.
  newEntry.Phonenumbers.Add(new PhoneNumber()
      {
        Primary = true,
        Rel = ContactsRelationships.IsWork,
        Value = "(206)555-1212",
      });
  newEntry.Phonenumbers.Add(new PhoneNumber()
      {
        Rel = ContactsRelationships.IsHome,
        Value = "(206)555-1213",
      });
  
  // 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);


Update Contact

 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


On Friday, August 31, 2012 12:26:05 PM UTC-7, Kathan shah wrote:
>
> i want to Create / Update / Delete Contact in Gmail using VB.NETapplication
>
> please help me with example
>

-- 
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" 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://code.google.com/apis/contacts/community/forum.html

Reply via email to