You can use QCurl commands to run Commvault REST APIs from the command line.
Before You Begin
Identify the REST API URL you need for the QCurl command. For example, to execute a QCurl command to list all clients in the CommCell, use the web service URL specified in REST API - GET Client. For more information, see Available Web Services for REST API.
Usage
qcurl [-cs <commserve_host_name>] -url <URL> -header <header> -req <request> -reqFile <XML file name> -op <operation> [-tf tokenfile] [-tk token] [-file outFile] [-h]
Options
-cs |
CommServer host name |
-url |
Web server URL |
-header |
Header |
-req |
XML request (POST) |
-reqFile |
XML request file (PUT/POST) |
-op |
REST API operations that you can perform from the command line. Valid values are:
|
-tf |
Reads token from a file |
-tk |
Token string |
-file |
File in which output is to be written |
-h |
Displays help |
Diagnostics
Possible exit status values are:
0 - Successful completion.
1 - CLI usage failures, due to the use of an unsupported option or missing argument.
2 - Any other failure.
Example
Retrieving Client Properties Using a Token File
-
Run the qlogin command to setup a token file and log on to the CommServe computer.
For example, create the
token.txt
file in theC
folder.qlogin -f "C:\token.txt" -u user1 Enter password: User logged in successfully
-
Execute the QCurl command to list all clients in the CommCell
qcurl -url "http:/<command_center_host_name>/commandcenter/api/Client" -op GET -tf "C:\token.txt"
Retrieving Client Properties Using the Default Session
-
Run the qlogin command to log on to the CommServe computer.
qlogin -u user1 Enter password: User logged in successfully
-
Execute the QCurl command to list all clients in the CommCell.
qcurl -url "http:/<command_center_host_name>/commandcenter/api/Client" -op GET
Writing content to a text file result.txt
-
Run the qlogin command to log on to the CommServe computer.
qlogin -u user1 Enter password: User logged in successfully
-
Execute the QCurl command to write content into a text file result.txt.
qcurl -cs <command_center_host_name> -url 'http:/<command_center_host_name>/commandcenter/api/Client/2' -op POST -file result.txt -header 'accept: application/xml' -header 'Content-Type: application/xml' -req "<App_SetClientPropertiesRequest> <association> <entity> <clientName>client2</clientName> </entity> </association> <clientProperties> <client> <clientDescription>client-level description modified with rest api POST client</clientDescription> </client> </clientProperties> </App_SetClientPropertiesRequest>"