0

I'm trying to retrieve phone numbers with respective labels from Google with the following code.

        RequestSettings settings = new RequestSettings("myapp", username, password){
                                                                                           UseSSL = true,
                                                                                           AutoPaging = true,
                                                                                           PageSize = 5000
                                                                                       };
        ContactsRequest c = new ContactsRequest(settings);
        Feed<Contact> feed = c.GetContacts();
        foreach (var entry in feed.Entries)
        {
            foreach (PhoneNumber phoneNumber in entry.Phonenumbers){
                Debug.Write(phoneNumber.Label ?? "Empty"); //Always null!
                Debug.Write(phoneNumber.Value ?? "Empty");//Have value
            }
        }

However, I had set label to the phone numbers in my Google account such as "Home", "Movile", but those values are not been returned. Am I missing something here?

Oscar
  • 13,594
  • 8
  • 47
  • 75

1 Answers1

0

The Contacts API uses the rel attribute for standard labels:

Custom labels are held in the label attribute, and these two attributes are mutually exclusive as described here.

Eric Koleda
  • 12,420
  • 1
  • 33
  • 51
  • Hello, thanks for taking your time to answer. In my case, I'm unable to get the value of my custom labels. Do you have a working code sample? – Oscar Jun 20 '14 at 07:04
  • In your original question you said you were using "Home" and "Mobile" as labels, which are not considered custom. Are you also using custom labels? – Eric Koleda Jun 20 '14 at 14:31
  • Yes, I had set custom labels to contacts, just used those words as a wrong sample. The real labels are in Spanish language. But as I said, the Value property always return null. About the code in my question, is this the proper way of retrieve a custom contacts's label? – Oscar Jun 20 '14 at 16:24
  • You seem to be doing it correctly. I ran a test using the Google OAuth2 Playground, and it returned the data correctly. Perhaps test out the request there and see if it's working for your account. – Eric Koleda Jun 20 '14 at 19:30