Example: User management using REST APIs

Creating a user

Method and URI:

POST "https://192.0.2.5/rest/v1/system/users"

Request body:

{
  "name": "myadmin",
  "password": "P@sswr0d",
  "user_group": "/rest/v1/system/user_groups/administrators",
  "origin": "configuration"
}

Example curl command:

$ curl -k POST \
-b /tmp/auth_cookie \
"https://192.0.2.5/rest/v1/system/users” –d '
{
  "name": "myadmin",
  "password": "P@sswr0d",
  "user_group": "/rest/v1/system/user_groups/administrators",
  "origin": "configuration"
}'

On successful completion, the switch returns response code 201 Created.

Changing a password

Method and URI:

PUT "https://192.0.2.5/rest/v1/system/users/myadmin"

Request body:

{
  "password": "P@sswr0d2g",
}

Example curl command:

$ curl -k -X PUT \
-b /tmp/auth_cookie \
"https://192.0.2.5/rest/v1/system/users/myadmin” –d '
{
  "password": "P@sswr0d2g",
}'

On successful completion, the switch returns response code 200 OK.

Deleting a user

Method and URI:

DELETE "https://192.0.2.5/rest/v1/system/users/myadmin"

Example curl command:

$ curl -k -X DELETE \
-b /tmp/auth_cookie \
"https://192.0.2.5/rest/v1/system/users/myadmin"

On successful completion, the switch returns response code 204 No Content.