Create user endpoint doesn't set email, groups and roles

Hi,

I’m using looker api v3.1. I’m trying to create a user with “POST/api/3.1/users” endpoint. It returns successful, but it doesn’t set user’s email, groups and roles. Email and roles are returning as null, groups field is not what I’ve sent.

Am I missing something? My request and responses are below:

Request:

{
  "email": "sample@email.com",
  "first_name": "Jhon",
  "is_disabled": false,
  "last_name": "Doe",
  "group_ids": [3],
  "role_ids": [5],
  "credentials_email": {
      "email": "sample@email.com",
      "is_disabled": false,
      "type": "email",
      "forced_password_reset_at_next_login": false
  }
}

Response:

{
    "avatar_url": "https://gravatar.lookercdn.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=156&d=blank",
    "avatar_url_without_sizing": "https://gravatar.lookercdn.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=blank",
    "credentials_api3": [],
    "credentials_email": null,
    "credentials_embed": [],
    "credentials_google": null,
    "credentials_ldap": null,
    "credentials_looker_openid": null,
    "credentials_oidc": null,
    "credentials_saml": null,
    "credentials_totp": null,
    "email": null,
    "first_name": "Jhon",
    "home_space_id": "1",
    "id": 15,
    "last_name": "Doe",
    "locale": "en",
    "looker_versions": [],
    "models_dir_validated": null,
    "personal_space_id": 20,
    "ui_state": null,
    "embed_group_space_id": null,
    "home_folder_id": "1",
    "personal_folder_id": 20,
    "presumed_looker_employee": false,
    "sessions": [],
    "verified_looker_employee": false,
    "roles_externally_managed": false,
    "allow_direct_roles": true,
    "allow_normal_group_membership": true,
    "allow_roles_from_normal_groups": true,
    "display_name": "Jhon Doe",
    "group_ids": [
        1
    ],
    "is_disabled": false,
    "role_ids": [],
    "url": "https://localhost:19999/api/3.1/users/15",
    "can": {
        "show": true,
        "index": true,
        "show_details": true,
        "index_details": true,
        "sudo": true
    }
}

Hi @mehmety

Email, groups, and roles are read-only for POST/api/3.1/users, meaning that the values for these keys can’t be changed (more info here, please take a look at “response class” https://docs.looker.com/reference/api-and-integration/api-reference/v3.1/user#create_user)

To update emails, groups, and roles, you would need to use other endpoints (i.e.: PUT/api/3.1/users/{user_id}/roles, …).

This article describes the workflow with setting up a new user with Looker Python SDK.

https://community.looker.com/technical-tips-tricks-1021/steps-for-creating-a-new-user-email-creds-role-group-via-python-sdk-26598

Hope this helps.

Thanks for your help @lantrann , I should have been more careful.