I'm working Google Apps Script. I can obtain all of my Google Contacts using the People API method People.People.Connections.list(). The response body contains an array of People called Connections, and an integer representing the total number of contacts returned, called totalItems (among other things).
When I run the following test,
function getConnections() {
try {
// Get the list of connections/contacts of user's profile
var people = People.People.Connections.list('people/me', {
personFields: 'names'
});
//Display the whole list
Logger.log('Connections: %s', JSON.stringify(people, null, 2));
} catch (err) {
Logger.log('Failed to get the connection with an error %s', err.message);
}
Logger.log(`totalItems: ${people.totalItems}`);
Logger.log(`length of people.connections: ${people.connections.length}`);
//Output the names of all the People in people.connections.
for(i = 0; i < people.connections.length ;i++){
if(people.connections[i] && people.connections[i].names){
Logger.log(i + " " + people.connections[i].names[0].displayName);
}
else {Logger.log("Something wrong with contact?")}
}
}
Logger outputs:
Info totalItems: 155
Info length of people.connections: 100
The for loop outputs the connection's names just fine, those that exist in the array anyway. Does anyone have any insight into this? Thank you in advance.