'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.
Solution 1:[1]
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.
Solution 2:[2]
Send "users(primaryEmail)" in the fields parameter, not in the customFieldMask parameter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lorena Gomez |
| Solution 2 | AMS |
