在 Debian 上用 Postman 测试接口,一般有 两种方式:
1️⃣ 安装 Postman 桌面版(推荐)
2️⃣ 使用 命令行版 Postman(Newman)
下面分别说明。
sudo apt update
sudo apt install snapd -y
sudo snap install postman
启动:
postman
或
snap run postman
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
tar -xvzf postman.tar.gz
cd Postman
./Postman
可创建桌面快捷方式:
sudo ln -s $(pwd)/Postman /usr/local/bin/postman
GET / POST / PUT / DELETEhttp://localhost:8080/api/test)Content-Type: application/json)适合 服务器 / CI 环境
sudo apt install nodejs npm -y
sudo npm install -g newman
test.jsonnewman run test.json
带环境变量:
newman run test.json -e env.json
假设本地有服务:
curl http://localhost:3000/api/hello
Postman 中:
GEThttp://localhost:3000/api/hellosudo apt install libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 -y
✅ 用 Newman(命令行)
如果你愿意,可以告诉我:
我可以直接给你 具体操作示例。