views:

166

answers:

2

Hi,

I am temporary creating one contact and immediatly after that i want to delete that contact. I am creating contact as follows:

ContactEntry[] ContactEntry = new ContactEntry[2];
ContactEntry[0] = new ContactEntry();
ContactEntry[0].Title.Text = "Temp";

Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
ContactEntry createdEntry = (ContactEntry)obj_ContactService.Insert(feedUri, ContactEntry[0]); 

In order to delete above contact if i use:

ContactEntry[0].Delete();

It is throwing Exception : "No Service object set".

Note: I am using Google Apps API Ver 2 for .NET

Thanx

A: 

This could help you out... http://code.google.com/apis/contacts/docs/2.0/developers_guide_dotnet.html#Deleting

Edit: As the API says, you need a ContactRequest instance to call the Delete method. I dont see that in the snippet you posted

Kay
+1  A: 

Rather than deleting the original data holder object you should delete the instance you got from the google server. Like this:

createdEntry.Delete();
Vitalik