views:

394

answers:

2

Hi,

How to create new "Custom Field into Google Contact using Google Contact API (c#)?

I used:

ExtendedProperty obj_ExtendedProperty = new ExtendedProperty(); 
 obj_ExtendedProperty.Name             = "Department";
 obj_ExtendedProperty.Value            = "Sales";
 ContactEntry.ExtendedProperties.Add(obj_ExtendedProperty);

Thanx

+1  A: 

Have a look to ContactEntry class and how to update it.

RETRIEVE your contact:

RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName,this.passWord);      
ContactsRequest cr = new ContactsRequest(rs);  
Contact contact = cr.Retrieve<Contact>("http://www.google.com/m8/feeds/contacts/[email protected]/full/12345");

UPDATE your contact:

UserDefinedField customField= new UserDefinedField("yourFieldName","yourFieldValue);  
contact.addUserDefinedField(customField);  
Contact updatedContact = cr.Update(contact);
systempuntoout
What is the "12345" in "http://www.google.com/m8/feeds/contacts/[email protected]/full/12345"?
Bryan
A: 

When I compile this, I get:

Error   1   The best overloaded method match for 'Google.GData.Client.FeedRequest<Google.GData.Contacts.ContactsService>.Retrieve<Google.Contacts.Contact>(Google.Contacts.Contact)' has some invalid arguments 
Error   2   Argument 1: cannot convert from 'string' to 'Google.Contacts.Contact'   

It is pointing to the line:

Contact contact = cr.Retrieve<Contact>("http://www.google.com/m8/feeds/contacts/[email protected]/full/12345");

Any idea why?

Thanks, Mark

Mark
If you change the retrieve argument to look like:Contact contact = cr.Retrieve<Contact>(new Uri("http://www.google.com/m8/feeds/contacts/[email protected]/full/12345"));then it compiles fine.
Mark