在 Ubuntu 上使用 Postman 测试接口一般分三步:安装 Postman → 创建请求 → 发送并查看结果。下面给你一个实用版教程。
sudo snap install postman
安装完成后,在应用菜单搜索 Postman 即可打开。
tar -xvf Postman-linux-x64-*.tar.gz
./Postman/Postman
(可选)创建快捷方式:
sudo ln -s /绝对路径/Postman/Postman /usr/local/bin/postman
假设接口地址:
http://localhost:8080/api/user/1
步骤:
http://localhost:8080/api/user?name=tom
或在 Params 中填写:
{
"username": "admin",
"password": "123456"
}
Content-Type: application/json
在 Headers 中添加:
Authorization: Bearer <你的token>
如果你只是想快速测:
curl http://localhost:8080/api/user/1
如果你愿意,可以告诉我:
我可以直接帮你写 Postman 配置示例或 curl 命令。