如何删除最近创建的 Google 联系人?
我暂时创建一个联系人,之后我想立即删除该联系人。 我正在创建联系人,如下所示:
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]);
为了删除上述联系人,如果我使用:
ContactEntry[0].Delete();
它会抛出异常:“未设置服务对象”。
注意:我正在使用适用于 .NET 的 Google Apps API Ver 2
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该删除从谷歌服务器获得的实例,而不是删除原始数据持有者对象。像这样:
Rather than deleting the original data holder object you should delete the instance you got from the google server. Like this:
这可以帮助你...
http://code.google.com/apis/contacts/ docs/2.0/developers_guide_dotnet.html#Deleting
编辑: 正如API所说,您需要一个ContactRequest实例来调用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