Updated on 2022-08-16 GMT+08:00

Run the curl Command to Access REST APIs

Description

You can use the curl tool to access the Manager REST API. Before running the curl command, run the openssl version command to check the OpenSSL version of the current operating system. If the version is earlier than OpenSSL 1.0.1, install the OpenSSL of a later version for the operating system. to support interaction with the cluster using TLSv1.1 and TLSv1.2.

For details about how to install and use curl, see related official documents.

Operation Example

  1. Send the GET method to access the user list query interface and save cookie to the /tmp/jsessionid.txt file.

    curl -k -i --basic -u <user name>:<password> -c /tmp/jsessionid.txt 'https://Manager floating IP address:28443/web/api/v2/permission/users?limit=10&offset=0&filter=&order=ASC&order_by=userName'

    <user name>: <password> indicates the user name and password that have the Manager operation rights.

  2. Use cookie to access the user group interface to add, modify, and delete user groups.
    • Send the POST method to add a user.

      curl -k -i -b /tmp/jsessionid.txt -X POST -HContent-type:application/json -d '{"userName":"user888","userType":"HM","password":"xxx","confirmPassword":"xxx","userGroups":["supergroup"],"userRoles":[],"primaryGroup":"supergroup","description":"Add user"}' 'https://Manager floating IP address:28443/web/api/v2/permission/users'

    • Send the PUT method to modify the user information.

      curl -k -i -b /tmp/jsessionid.txt -X PUT -HContent-type:application/json -d '{"userName":"user888","userType":"HM","password":"","confirmPassword":"","userGroups":["supergroup","hadoopmanager"],"primaryGroup":"supergroup","userRoles":[],"description":"Modify user"}' 'https://Manager floating IP address:28443/web/api/v2/permission/users/user888'

    • Send a DELETE method to delete a user.

      curl -k -i -b /tmp/jsessionid.txt -X DELETE -HContent-type:application/json -d '{"userNames":["user888"]}' 'https://Manager floating IP address:28443/web/api/v2/permission/users'