在 Ubuntu 上使用 Postman 测试接口,一般有两种方式:
下面分别说明。
sudo snap install postman
安装完成后,在应用菜单搜索 Postman 即可打开。
.deb 或 tar 包)PostmanGETPOSTPUTDELETE例如:
http://localhost:8080/api/user
id1rawJSON{
"username": "test",
"password": "123456"
}
常见示例:
Content-Type: application/json
Authorization: Bearer token值
点击 Send
假设 Ubuntu 上运行了一个接口:
GET http://127.0.0.1:3000/api/hello
Postman 中:
http://127.0.0.1:3000/api/hellobase_url = http://localhost:8080{{base_url}}/api/user
好处:切换测试/生产环境很方便
适合 CI / 自动化测试。
sudo apt install nodejs npm
sudo npm install -g newman
test.jsonnewman run test.json
sudo snap refresh postman
或重新安装
如果你愿意,可以告诉我:
我可以给你一个 具体接口的 Postman 配置示例。