Retrieve google contact based on contact Id

穿精又带淫゛_ 提交于 2019-12-12 20:31:00

问题


When I issue a contacts request to get all of a user's contacts I get contacts Id's of the form:

http://www.google.com/m8/feeds/contacts/sometestaccount%40gmail.com/base/4f822c758a541b6b

Reading the google contacts api 3.0 I was a bit confused on what uri should I use to delete a contact. Doing:

var cr = new ContactsRequest(settings);
var uri = new Uri("http://www.google.com/m8/feeds/contacts/sometestaccount%40gmail.com/base/4f822c758a541b6b");
var contact = cr.Retrieve<Contact>(uri);
cr.Delete(contact);

fails with

Google.GData.Client.GDataRequestException : Execution of request returned unexpected result: http://www.google.com/m8/feeds/contacts/sometestaccount%40gmail.com/base/4f822c758a541b6b?max-results=50MovedPermanently

What's the correct way to get a contact Id and request for a contact deletion? Thanks in advance.


回答1:


I did some research on this and I found 2 errors.

1) I got a "Moved permanently because I issued my request in http and I should have done that in https.

2) The uri format is strictly :

https://www.google.com/m8/feeds/contacts/{userEmail}/full/{contactId}

I had a setting.Pagesize = 50 , which caused my uri to be

https://www.google.com/m8/feeds/contacts/{userEmail}/full/{contactId}?max-results=50

which is invalid and returns a 400 bad request.

The contact Id is the hash code that you get from the contact.Id result uri. After you retrieve the contact entry, the deletion is as documented in the google api contacts v3.0 .



来源:https://stackoverflow.com/questions/23697026/retrieve-google-contact-based-on-contact-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!