You can update a user using the CLI tool or REST API as shown below:
The user's username can not be changed in the updating process.
Updating a user via the CLI
Overview
CLI command | update-user |
Description | Update a specific user. |
Command format | update-user -u <USERNAME> -p <PASSWORD> -r <ROLE_NAME> -f <FIRST_NAME> -l <LAST_NAME> -e <EMAIL> -pr <PROFILE_NAME> |
Parameter definition
Short option | Long option | Description | Required | Example value |
---|---|---|---|---|
-u |
| Username given to the user. | Yes | kim |
-p |
| User's password. | Yes | admin123 |
-r | --role-name | Role assigned to the user. | Yes | admin |
-f |
| User's first name. | Yes | Kim |
-l |
| User's last name. | Yes | Myers |
-e |
| User's email address. | Yes | [email protected] |
-pr | --profile-name | User's profile name. | Yes | dev |
Example
Update the user with the username: kim.
User updated successfully: kim
Sample output
User added successfully: [user] kim
Updating a user via the REST API
Overview
Description | Update a specific user. |
Resource Path | /users |
HTTP Method | PUT |
Request/Response Format | application/json |
Command format | curl -X PUT -H "Content-Type: application/json" -d @'<JSON_PAYLOAD>' -k -v -u <USERNAME>:<PASSWORD> https://<PRIVATE_PAAS_HOST>:<PRIVATE_PAAS_HTTPS_PORT>/api/users
|
Example
Add the user defined in the user.json
file.
curl -X PUT -H "Content-Type: application/json" -d @'user.json' -k -v -u admin:admin https://localhost:9443/api/users
Sample output
> PUT /api/users HTTP/1.1 > Host: localhost:9443 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.43.0 > Accept: */* > Content-Type: application/json > Content-Length: 136 > < HTTP/1.1 200 OK < Date: Wed, 14 Oct 2015 04:51:47 GMT < Content-Type: application/json < Transfer-Encoding: chunked < Server: WSO2 Carbon Server < {"status":"success","message":"User updated successfully: [user] kim"
You will come across the following HTTP status codes while adding a user:
HTTP status code | 201, 404, 500 See the descriptions of the HTTP status codes here. |
Sample user JSON
{ "userName": "kim", "credential": "kim12345", "role": "admin", "firstName": "Frank", "lastName": "Myers", "email": "[email protected]" }
Overview
Content Tools
Activity