开发者

How to delete recently created Google Contact?

开发者 https://www.devze.com 2022-12-27 06:53 出处:网络
I am temporary creating one contact and immediatly after that i want to delete that contact. I am creating contact as follows:

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]);开发者_如何学Python 

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


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

createdEntry.Delete();


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

0

精彩评论

暂无评论...
验证码 换一张
取 消