在 Debian 上用 Postman 测试接口,一般有两种方式:
下面分别说明。
Postman 官方提供 .deb 包:
# 下载
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
# 解压
sudo tar -xzf postman.tar.gz -C /opt
# 创建快捷方式
sudo ln -s /opt/Postman/Postman /usr/bin/postman
然后命令行输入:
postman
或通过菜单启动。
GET / POST / PUT / DELETEhttp://localhost:8080/api/testAuthorization、Content-Type)适合 服务器 / CI 测试
sudo apt update
sudo apt install nodejs npm -y
sudo npm install -g newman
验证:
newman --version
.json)newman run api_test.json
带环境变量:
newman run api_test.json -e env.json
GET http://127.0.0.1:8080/user/1
{
"username": "test",
"password": "123456"
}
Header:
Content-Type: application/json
curl 测试:curl http://localhost:8080/api/test
如果你愿意,可以告诉我:
我可以给你更具体的示例。