在 Linux 下使用 Postman 测试接口,一般有两种方式:
# 下载
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
# 解压
tar -xzf postman.tar.gz
# 运行
./Postman/Postman
sudo snap install postman
GET / POST / PUT / DELETEhttp://localhost:8080/api/testAuthorization)form-datax-www-form-urlencodedraw(JSON)sudo apt install nodejs npm -y
sudo npm install -g newman
test.postman_collection.jsonnewman run test.postman_collection.json
newman run test.postman_collection.json \
-e env.postman_environment.json
如果你只是临时测接口,也可以直接用:
curl -X POST http://localhost:8080/api/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"123456"}'
| 场景 | Postman 配置 |
|---|---|
| 登录鉴权 | Headers 加 Authorization: Bearer token |
| 文件上传 | Body → form-data → File |
| Cookie | Cookies 面板 |
| 自动化测试 | Tests 标签写 JS 断言 |
如果你愿意,可以告诉我:
我可以给你更具体的示例。