Search code examples
google-admin-sdkgoogle-directory-api

Users insert method doesn't store secondary e-mail


Is there a option to store user's secondary email using the Google Directory API?

I am just trying to use "emails" property (according to it https://developers.google.com/admin-sdk/directory/v1/reference/users/insert), but it didn't work.

Here is request body example that I am using:

{
    "name": {
        "familyName": "John",
        "givenName": "Doe",
        "fullname": "John Doe"
    },
    "primaryEmail": "john.doe@somesite.edu.br",
    "password": "somepasswordhere",
    "emails": {
        "address": "some.secondary.email.here@gmail.com",
        "primary": false,
        "type": "other",
    },
    "organizations": {
        "name": "Some Organization",
        "department": "Blah",
        "title": "Test",
        "type": "school",
    },
    "changePasswordAtNextLogin": true,
    "relations": {
        "type": "mother",
        "value": "John's Mother"
    }
}

Solution

  • Sorry. My bad.

    The "emails" property expects a list and not a object like the request body I put.

    So, the final request body is:

    "emails": [{
        "address": "some.secondary.email.here@gmail.com",
        "primary": false,
        "type": "other",
    }],