Question

Trying to retrieve a single contact. In the link, it says:

public static Contact retrieveContact(ContactsRequest cr)
{
  Contact contact = cr.Retrieve<Contact>("https://www.google.com/m8/feeds/contacts/default/full/contactId");
  return contact;
}

How would one know what's the contact's selflink URL, or even the contactId? I tried different variations:

https://www.google.com/m8/feeds/contacts/default/full/firstname.lastname https://www.google.com/m8/feeds/contacts/ourdomain.com/full/firstname.lastname https://www.google.com/m8/feeds/contacts/firstname.lastname%40ourdomain.com/full/firstname.lastname

But I can't seem to get a proper return value. All I am getting is Not Found exception.

Full error message is:

{"The remote server returned an error: (404) Not Found."}

I am able to connect to the service, as I am able to do a proper query if I retrieve all contacts. But getting a bit stumped on retrieving a single contact.

Anyone already worked on this?

Appreciate any advice.

Update: If for example you use the ContactsQuery such as:

    ContactsQuery query =
                    new ContactsQuery("https://www.google.com/m8/feeds/profiles/domain/" + this.domain + "/full");
query.Query = ?????

What can we specify in the query object so that we can actually just go retrieve one user (based on user name or email address)?

Update: I used GAM (https://code.google.com/p/google-apps-manager/) to retrieve a particular user and there was an ID field there composed of a bunch of numbers. I tried to use that in lieu of the ContactID field in the URI as above, but all variations just returns a 403 Not Found error.

Was it helpful?

Solution 2

You need to know the contactId ahead of time. It is not possible to look up a Contact record from their email address with the Contacts API.

If you are just looking for users in your domain, then check out the Directory API - https://developers.google.com/admin-sdk/directory/v1/guides/manage-users#get_user

OTHER TIPS

 public Contact GetContact(ContactsRequest cr, string email)
    {
        string qstring = "https://www.google.com/m8/feeds/contacts/default/full?q=" + email + "&v=3.0";
        Uri thisuri = new Uri(qstring);
        Contact contact = cr.Retrieve<Contact>(thisuri);
        return contact;
    }

When you use the search: www.google.com/m8/feeds/contacts/default/full?q=lastname+firstname+... you can limit the results to those you want to update. When fetching the "id" from the "entry" results you will notice it is formed like "http://www.google.com/m8/feeds/contacts/yourself%40gmail.com/base/7e" The id, 7e in this case, is after "/base/".

When using www.google.com/m8/feeds/contacts/default/full/7e , you will get the entry of the requested user.

You can deduce this from the info at https://developers.google.com/google-apps/contacts/v3/#retrieving_a_single_contact

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top