Adding a Contact with the Google Contacts .NET API
Posted
by Bryan
on Stack Overflow
See other posts from Stack Overflow
or by Bryan
Published on 2010-04-27T01:05:57Z
Indexed on
2010/04/27
1:13 UTC
Read the original article
Hit count: 653
I am using the following code to add a contact, but I get the following unhandled exception: Google.GData.Client.GDataRequestException: Execution of request failed: http://www.google.com/m8/feeds/contacts/default/full
GDataCredentials myCred = new GDataCredentials("myusername", "mypassword");
RequestSettings myRequestSettings = new RequestSettings("macpapa-GoogleCodeTest3-1", myCred);
ContactsRequest myContactRequest = new ContactsRequest(myRequestSettings);
Contact myContact = new Contact();
myContact.Title = "Be Dazzle";
PhoneNumber myPhoneNumber = new PhoneNumber("805-453-6688");
myPhoneNumber.Rel = ContactsRelationships.IsGeneral;
myPhoneNumber.Primary = true;
myContact.Phonenumbers.Add(myPhoneNumber);
EMail myEmail = new EMail("[email protected]", ContactsRelationships.IsHome);
EMail myEmail2 = new EMail("[email protected]", ContactsRelationships.IsWork);
myEmail.Primary = true;
myContact.Emails.Add(myEmail);
myContact.Emails.Add(myEmail2);
PostalAddress postalAddress = new PostalAddress();
postalAddress.Value = "123 somewhere lane";
postalAddress.Primary = true;
postalAddress.Rel = ContactsRelationships.IsHome;
myContact.PostalAddresses.Add(postalAddress);
Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
Contact createdContact = myContactRequest.Insert<Contact>(feedUri, myContact);
Please offer any available suggestions. Thank you.
© Stack Overflow or respective owner