IMTheNachoMan
IMTheNachoMan

Reputation: 5821

How to get only specific fields with Google Directory API users.list

The documentation (https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/list#query-parameters) says you can use customFieldMask to get only specific fields. I cannot figure out the format/structure of this property.

For example, given this for a user:

{
  "kind": "admin#directory#user",
  "id": "...",
  "etag": "\"...\"",
  "primaryEmail": "...",
  "name": {
    "givenName": "...",
    "familyName": "...",
    "fullName": "......"
  },
  "emails": [
    {
      "address": "...",
      "primary": true
    }
  ]
}

I only want to get primaryEmail but I can't figure out how.

Upvotes: 1

Views: 1519

Answers (2)

AMS
AMS

Reputation: 253

Send "users(primaryEmail)" in the fields parameter, not in the customFieldMask parameter.

Upvotes: 2

Lorena Gomez
Lorena Gomez

Reputation: 2203

The Directory API can't retrieve the 'primaryEmail' with the customFieldMask attribute, with this attribute you can only specify the custom schema names that you create in the Admin console.

Upvotes: 0

Related Questions