google-apps-scriptgoogle-contacts-api

Name field not being returned for a contact


When I go to pull the full name on a certain contact (getFullName()) my script doesn't return any thing. However, when I make a change to the name from within the Gmail Contacts interface, it then returns the name. If I undo the change, I don't get the name.

Any reasons to this? The contact is another account of mine that's tied to my G+ account.


Solution

  • This is a very interesting find. I was able to reproduce this with some of my contacts as well. It must have something to do with the where these contacts were imported from or how they were manually created.

    However, I dug a bit deeper and I do not believe this is an Apps Script issue, but a Google Apps Contact API issue. I found this same issue directly interaction with the Google Contacts API documented here -

    https://developers.google.com/google-apps/contacts/v3/

    This might be the same issue tracked in their issue tracker as #3171.

    Bit more of the technical details of what I tried to confirm this -

    a. Go to the oAuth playground at - https://developers.google.com/oauthplayground and authorize manually for the scope of https://www.google.com/m8/feeds.

    Once you click authorize, the tool will make your login and then authorize the playground tool to read your contacts. oAuth Playground

    b. Now, click the "Exchange Authorization Tokens" button to grab the final token for further REST calls. Get final authorization token

    c. Set the Request URI to https://www.google.com/m8/feeds/contacts/default/full and hit "Send the Request". You should get the XML dump on the right. Copy and view it in your favorite XML editor and you should see the same behavior you are describing above where Fullname only returns after an edit. You can narrow this down to invididual contacts (and stare at smaller XML files) by passing in a contact ID in the URL format of https://www.google.com/m8/feeds/contacts/default/full/{contactId}

    Get contacts data back