在 Ubuntu 上使用 Postman 调试接口,一般有两种方式:
下面以 桌面版 为例,讲清楚怎么调试接口。
sudo snap install postman
.tar.gz)tar -xzf Postman-linux-x64-*.tar.gz
./Postman/Postman
登录接口)示例(调试一个接口):
GET / POST / PUT / DELETEhttp://localhost:8080/api/login
username=admin
password=123456
{
"username": "admin",
"password": "123456"
}
点击 Send
你可以看到:
例如:
Content-Type: application/json
Authorization: Bearer tokenxxx
示例:
http://localhost:8080https://api.xxx.com设置:
base_url请求 URL 写:
{{base_url}}/api/login
如果接口报错:
tail -f logs/app.log
确保:
curl http://localhost:8080/api/login
如果 curl 通,Postman 不通,可能是:
https / http 写错打开:
View → Show Postman Console
可以看到:
sudo snap refresh postman
或重新安装
Postman → Settings → SSL Certificate Verification → OFF(仅测试)
POST {{base_url}}/api/login
Content-Type: application/json
{
"username": "admin",
"password": "123"
}
如果你愿意,可以告诉我:
我可以直接帮你写 Postman 配置示例。