Search code examples
google-people-api

Get contacts of a group using google people api


So far, the existing questions and answers have not helped me. I am trying to get the online "try this API" to work for me. people.connections.list and contactGroups.get work for me. However, I can not find a way to get a list of contacts for a given group. It seems like this should be simple.


Solution

  • Try this:

    1. Use contactGroups.get and specify a non-zero maxMembers parameter.
    2. List the array memberResourceNames[] from the returned ContactGroup object.
    {
      "resourceName": string,
      "etag": string,
      "metadata": {
        object (ContactGroupMetadata)
      },
      "groupType": enum (GroupType),
      "name": string,
      "formattedName": string,
      "memberResourceNames": [
        string
      ],
      "memberCount": integer,
      "clientData": [
        {
          object (GroupClientData)
        }
      ]
    }
    
    1. Use people.getBatchGet using the retrieved resource names.

    I did a contactGroups.list first. For your step 1. I had to set the resourceName = contactGroups/hex value from the list The output does not look like yours

    {
      "resourceName": "contactGroups/443...",
      "etag": "k+...,
      "metadata": {
        "updateTime": "2020-11-08T15:29:59.193Z"
      },
      "groupType": "USER_CONTACT_GROUP",
      "name": "Tennis",
      "formattedName": "Tennis",
      "memberCount": 46
    }
    

    EDIT: The memberResourceNames array only appears if you specify >0 on maxMembers parameter.