Add User Role to User
The Add User Role to User operation adds a specified User Role to a specified user. This operation is not valid for system-defined or pattern-based users.
HTTP method and URI
POST /api/users/{user-id}/operations/add-user-role
In this request, the URI variable {user-id} is the object ID of the user to which a User Role is to be added or the special keyword value "this-user" which designates the API user that issued the request.
Request body contents
The request body is expected to contain a JSON object with the following field:
Field name | Type | Rqd/Opt | Description |
---|---|---|---|
user-role-uri | String/ URI | Required | The canonical URI path of the User Role to be added. |
Description
This operation adds a User Role to a user.
On successful execution of this operation the User Role specified in the request body has been added to the user identified in the request URI.
The request body is validated against the schema described in Request body contents. If the request body is not valid, status code 400 (Bad Request) is returned with a reason code indicating the validation error encountered. If the request URI does not designate an existing User object, status code 404 (Not Found) is returned. If the API user does not have user-related-access permission to the designated User object or action/task permission to the Manage Users or Manage User Templates task, whichever is appropriate, status code 404 (Not Found) is returned. If the API user has user-related-access permission to the designated User object but not action/task permission to the Manage Users or Manage User Templates task, whichever is appropriate, status code 403 (Forbidden) is returned. If the request body does not designate an existing User Role, status code 404 (Not Found) is returned. If the specified object is already in the collection of the user's User Roles, status code 409 (Conflict) is returned. An attempt to update the User Role collection of a system-defined or pattern-based user is not valid and fails with status code 400 (Bad Request).
If this operation changes the value of any property for which property-change notifications are due, those notifications are emitted asynchronously to this operation.
Authorization requirements
- Action/task permission to the Manage Users task to modify a standard user or the Manage User Templates task to modify a template user.
HTTP status and reason codes
On success, HTTP status code 204 (No Content) is returned and no response body is provided.
The following HTTP status codes are returned for the indicated errors, and the response body is a standard error response body providing the reason code indicated and associated error message.
HTTP error status code | Reason code | Description |
---|---|---|
400 (Bad Request) | Various | Errors were detected during common request validation. See Common request validation reason codes for a list of the possible reason codes. |
314 | This operation is not supported for an object of this type. The User Role collection of system-defined and pattern-based users may not be altered. | |
403 (Forbidden) | 1 | The API user does not have the required permission for this operation. |
404 (Not Found) | 1 | The request URI does not designate an existing resource of the correct type or the API user has no access permission to it. |
2 | A URI in the request body does not designate an existing resource of the correct type. | |
409 (Conflict) | 315 | The object designated by the URI in the request body is already in the user's collection of User Roles. |
Additional standard status and reason codes can be returned, as described in Invoking API operations.