Postman 10.x Tutorial (Latest) - Using the Postman CLI

Опубликовано: 26 Январь 2023
на канале: QASCRIPT
2,318
20

Postman CLI is a command line tool which is secured and supported by Postman.

Postman CLI can be used to:
Run a collection using its ID or path
Send run results to Postman
Log in and Log out using the API Keys
Check API definitions

Difference between Postman CLI and Newman:
Postman CLI is maintained and supported by Postman but Newman is supported by community
Postman CLI is distributed as a downloadable package but Newman is distributed on npm
Postman CLI is not available as a library but Newman is available as a library
Postman CLI supports login and log out but Newman doesn't support this feature

Command to install Postman CLI on Windows:
powershell.exe -NoProfile -InputFormat None -ExecutionPolicy AllSigned -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://dl-cli.pstmn.io/install/win64...)"

Command to install Postman CLI on Mac:
curl o "https://dl-cli.pstmn.io/install/osx_a..." | sh

Command to install Postman CLI on Linux:
curl o "https://dl-cli.pstmn.io/install/linux..." | sh

Postman CLI Commands:

postman -v : Returns the version of the Postman CLI
postman -h: Returns information about Postman CLI commands
postman login --with-api-key [api-key]: Authenticates the user and caches locally
postman logout: Logs out the user from Postman and deletes the API key
postman collection run [collection-id]

Example:
postman login --with-api-key {{postman-api-key-here}}
postman collection run [collection-id] -e [environment-id]