Usage examples in CURL
The following examples show how to use CURL for authentication and user management.
Each curl example takes the following form:
curl -L -X POST https://system_ip:7443/rest/v1target -H
header_1 -H header_2 data-raw 'JSON'
Where the following definitions apply:
Authentication
The following is an example of the correct procedure for authenticating. You authenticate by first creating an authentication token and then using that token in all future commands until the session ends. For more information on authentication, see Authentication overview.
curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Username:
superuser' -H 'X-Auth-Password: passw0rd'
https://192.168.10.109:7443/rest/v1/auth
This yields an authentication token that you use for all other
commands.
{"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MTk2MTg3ODAsImV4cCI6MTYxOTY
yMjM4MCwianRpIjoiMGRjYWRkMWIyODNlNDc5ZGI3ZTJkNzZmZmJlMGI2NjAiLCJzdiI6eyJ1c2VyI
joic3VwZXJ1c2VyIn19.f_NzcKZEUUf3UWaH4JQeasi7BPSTkBcfPe9AMrQOeQyEXp7ZU9wsJn7E9A
jjaIKVM7UsT22HvslLVo5LXTNEkg'"}
Making a new user
The following example shows how to create a new user, setting a password, and adding a user to a
specific group. The example also demonstrates the use of the token in place of the authentication
headers that are used in the authentication
process:
curl -L -X POST '<system_ip>:7443/rest/v1/mkuser' -H 'X-Auth-Token:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MTk2MTg3ODAsImV4cCI6MTYxOTYy
MjM4MCwianRpIjoiMGRjYWRkMWIyODNlNDc5ZGI3ZTJkNzZmZmJlMGI2NjAiLCJzdiI6eyJ1c2VyI
joic3VwZXJ1c2VyIn19.f_NzcKZEUUf3UWaH4JQeasi7BPSTkBcfPe9AMrQOeQyEXp7ZU9wsJn7E9
AjjaIKVM7UsT22HvslLVo5LXTNEkg' -H 'Content-Type: application/json'
--data-raw '{"name": "testuser", "usergrp": "Service", "password": "testpassw0rd"}'
Changing password by using the username
The following example shows how to set a new user password for a user and demonstrates the use of
the token in place of the authentication headers used in the authentication
process:
curl -L -X POST '<system_ip>:7443/rest/chuser/testuser' -H 'X-Auth-Token:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MTk2MTg3ODAsImV4cCI6MTYxOTY
yMjM4MCwianRpIjoiMGRjYWRkMWIyODNlNDc5ZGI3ZTJkNzZmZmJlMGI2NjAiLCJzdiI6eyJ1c2V
yIjoic3VwZXJ1c2VyIn19.f_NzcKZEUUf3UWaH4JQeasi7BPSTkBcfPe9AMrQOeQyEXp7ZU9wsJn
7E9AjjaIKVM7UsT22HvslLVo5LXTNEkg' -H 'Content-Type: application/json'
--data-raw '{"password": "newPassw0rd"}'
Changing password using the ID
The following example shows how to change a user password for a user by using the user ID. In
this example, 2 is used as the user
ID.
curl -L -X POST '<system_ip>:7443/rest/chuser/2' -H 'X-Auth-Token:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MTk2MTg3ODAsImV4cCI6MTYxOTY
yMjM4MCwianRpIjoiMGRjYWRkMWIyODNlNDc5ZGI3ZTJkNzZmZmJlMGI2NjAiLCJzdiI6eyJ1c2V
yIjoic3VwZXJ1c2VyIn19.f_NzcKZEUUf3UWaH4JQeasi7BPSTkBcfPe9AMrQOeQyEXp7ZU9wsJn
7E9AjjaIKVM7UsT22HvslLVo5LXTNEkg' -H 'Content-Type: application/json'
--data-raw '{"password": "newPassw0rd"}'
Listing all users
The following example lists all user using version 1 of the
API:
curl -L -X POST '<system_ip>:7443/rest/v1/lsuser' -H 'X-Auth-Token:eyJ0eX
AiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MTk2MTg3ODAsImV4cCI6MTYxOTYyMjM4MCwian
RpIjoiMGRjYWRkMWIyODNlNDc5ZGI3ZTJkNzZmZmJlMGI2NjAiLCJzdiI6eyJ1c2VyIjoic3VwZXJ1c2V
yIn19.f_NzcKZEUUf3UWaH4JQeasi7BPSTkBcfPe9AMrQOeQyEXp7ZU9wsJn7E9AjjaIKVM7UsT22Hvs
lLVo5LXTNEkg' -H 'Content-Type: application/json' --data-raw ''
Listing details about a user
The following example shows how to list a user in a version 1 of the API by using the user
ID:
curl -L -X POST '<system_ip>:7443/rest/v1/lsuser/3' -H 'X-Auth-Token:eyJ0
eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MTk2MTg3ODAsImV4cCI6MTYxOTYyMjM4MCw
ianRpIjoiMGRjYWRkMWIyODNlNDc5ZGI3ZTJkNzZmZmJlMGI2NjAiLCJzdiI6eyJ1c2VyIjoic3VwZX
J1c2VyIn19.f_NzcKZEUUf3UWaH4JQeasi7BPSTkBcfPe9AMrQOeQyEXp7ZU9wsJn7E9AjjaIKVM7Us
T22HvslLVo5LXTNEkg' -H 'Content-Type: application/json' --data-raw ''
Removing a user
The following example shows how to remove a user by using the user ID in a version 1 of the
API:
curl -L -X POST '<system_ip>:7443/rest/v1/rmuser/2' -H 'X-Auth-Token:eyJ
0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MTk2MTg3ODAsImV4cCI6MTYxOTYyMjM4MC
wianRpIjoiMGRjYWRkMWIyODNlNDc5ZGI3ZTJkNzZmZmJlMGI2NjAiLCJzdiI6eyJ1c2VyIjoic3VwZ
XJ1c2VyIn19.f_NzcKZEUUf3UWaH4JQeasi7BPSTkBcfPe9AMrQOeQyEXp7ZU9wsJn7E9AjjaIKVM7U
sT22HvslLVo5LXTNEkg' -H 'Content-Type: application/json' --data-raw ''