Search code examples
google-apigoogle-api-clientgoogle-people-api

Is resourceNames comma separated in Google people getBatchGet?


https://developers.google.com/people/api/rest/v1/people/getBatchGet

resourceNames string

The resource names of the people to provide information about.

To get information about the authenticated user, specify people/me. To get information about a google account, specify people/account_id. To get information about a contact, specify the resource name that identifies the contact as returned by people.connections.list. You can include up to 50 resource names in one request.

It specifies resourceNames to be string, but does not mention whether it's comma separated or not, while personFields is comma separated.

In official clients, it's type is also string, so I am guessing it is comma separated?

I am using Node by the way: https://github.com/google/google-api-nodejs-client/blob/master/src/apis/people/v1.ts#L2399

Its type is strictly string.


Solution

  • When you want to use the several resourceNames, please use the following query parameter.

    GET https://people.googleapis.com/v1/people:batchGet?requestMask.includeField=emailAddresses,names&resourceNames=people/me&resourceNames=people/123456789
    

    When you use this, please encode as follows.

    GET https://people.googleapis.com/v1/people:batchGet?requestMask.includeField=emailAddresses%2Cnames&resourceNames=people%2Fme&resourceNames=people%2F123456789
    

    Reference

    If I misunderstand your question, I'm sorry.

    Added :

    When you want to use it at googleapis, please use it as 1 dimensional array.

    const people = google.people({version: 'v1', auth});
    people.people.getBatchGet({
        resourceNames: ['people/me', 'people/123456789',,,],
        personFields: 'emailAddresses,names',
    }, (err, res) => {
        if (err) {
            console.log(err);
        } else {
            console.log(res.data);
        }
    });