Set

[POST] .../v1/userrole/set

Assigns a role to a user. Assign a role directly to a user after selecting the user and role. The method validates role_id and user_id, rejects user_id 1 to protect the built-in Administrator, checks user-role set permission 13, inserts the assignment and returns new_id. The request body is required, role_id and user_id must both be positive and this method changes only the direct user-role assignment table. Missing body, invalid ids, Administrator assignment attempts, denied permission, duplicate assignment conflicts and storage errors are returned as HTTP 200 ErrorResult.

Request Parameters

Name Type Required Description
role_id Int64 Required Role ID.
user_id Int64 Required User ID.

Request Example

{
  "user_id": 17,
  "role_id": 4
}

Response Parameters

Name Type Description
ok Boolean Indicates whether the request completed successfully.
result Insert Created record result.

Response Example

{
  "ok": true,
  "result": {
    "new_id": 51
  }
}