Apidog CLI
Apidog CLI is mainly designed to run Apidog test cases in the command line. It is used for automation testing.
Command Options
Install CLI
The Apidog CLI relies on Node.js version number >= v10. Please install Node.js before using it.
sudo npm install -g apidog-cli
Command-line Options
Command Parameters
apidog [options]
-h, --help
View help information.
-v, --version
Show Apidog version.
apidog run <file-source> [options]
file-source
needs to be the path for test cases
files exported from Apidog.
More Options
-r, --reporters [reporters] Specify test report file extension, support cli, html, json (default: ["cli"])
--out-dir <outDir> Test report final export dir, by default is apidog-reports folder in the current dir (default:"./apidog-reports")
--out-file <outFile> Test report name, ignore file extension name, by default is apidog-report-{timestamp}-0
--out-json-failures-separated <outJsonFailuresSeparated> When generating a JSON report for test results, export the details of failures to a separate JSON file
-n, --iteration-count <n> Define the number of iterations to run
-d, --iteration-data <path> Define the data which use for iterations (either JSON or CSV)
--global-var <value> Specifies global variables, in a key=value format. Multiple CLI global variables can be added, for example: --global-var "user=123" --global-var "password=123"
--env-var <value> Specifies environment variables, in a key=value format. Multiple CLI environment variables can be added, for example: --env-var "user=123" --env-var "password=123"
--external-program-path <path> Specify the file path of external program, by default is current directory
--database-connection <path> Specify the file path of database configuration, it is required when CLI run with URL
--ignore-redirects Prevent Apidog from automatically following 3XX redirect response
--silent Prevent Apidog CLI from showing output
--color <value> Enable/Disable colored output (auto|on|off) (default: "auto")
--delay-request [n] Specify the extent of delay between requests (milliseconds) (default: 0)
--timeout-request [n] Specify a timeout for requests (milliseconds) (default: 0)
--timeout-script [n] Specify a timeout for pre/post requests (milliseconds) (default: 0)
-k, --insecure Disables SSL validations
--ssl-client-cert-list <path> Specify the path to a client certificates configurations (JSON)
--ssl-client-cert <path> Specify the path to a client certificate (PEM)
--ssl-client-key <path> Specify the path to a client certificate private key
--ssl-client-passphrase <passphrase> Specify the client certificate passphrase (for protected key)
--ssl-extra-ca-certs <path> Specify additionally trusted CA certificates (PEM)
-b, --bigint Compatible bigint (default: false)
--verbose Show detailed information of each request
-h, --help display help for command
SSL
Client Certificate
Apidog CLI supports passing in client certificates.
Using Single SSL Client Certificate
--ssl-client-cert
Specify the path of the public SSL client certificate.--ssl-client-key
Specify the path of the private SSL client certificate (optional).--ssl-client-passphrase
Specify SSL client passphrase (optional).
Using SSL Client Certificates Configuration File (supports multiple certificates)
--ssl-client-cert-list
Specify the path of the JSON file of the SSL client certificate list. For example:ssl-client-cert-list.json
ssl-client-cert-list.json
[
{
"name": "domain1",
"matches": ["https://test.domain1.com/*", "https://www.domain1/*"],
"key": {"src": "/CI/client.domain1.key"},
"cert": {"src": "/CI/client.domain1.crt"},
"passphrase": "changeme"
},
{
"name": "domain2",
"matches": ["https://domain2.com/*"],
"key": {"src": "/CI/client.domain2.key"},
"cert": {"src": "/CI/client.domain2.crt"},
"passphrase": "changeme"
}
]
This option supports setting different SSL client certificates based on URL or hostname. It takes precedence over the --ssl-client-cert
, --ssl-client-key
, and --ssl-client-passphrase
options. These options will be used as fallback options if there is no match for the URL in the list.
Version Upgrade
CLI Use the command below to upgrade the Apidog version.
$ npm install apidog-cli@latest -g
Use the CLI
There are two usage scenarios of Apidog CLI, please click the title to view the details:
- Run online data in real time
- Run a test file that has been exported locally
FAQs
How to Fix the Error when Using CLI?
- Invalid character in header content["Authorization"]
Getting Invalid character in header content
error after running Apidog CLI command in terminal:
To make sure there are no abnormalities when running automated tests in Apidog client/web, please check whether remote values are set in environment.
How to Pass File Parameters Using CLI?
- First, go back to the request parameters in the "APIs" → "Edit" → "Bulk Edit". Change the path of the uploaded file to a variable by batch editing.
After saving as an API use case, import
API Cases
inTesting
.Finally, when running in the corresponding application (such as jenkins), modify the actual value of this path variable.