在 Debian 上使用 Postman 发送 HTTP 请求,一般有 两种方式:
1️⃣ 安装 Postman 桌面版(推荐)
2️⃣ 使用 Postman CLI(newman) 或通过命令行模拟(curl)
下面我按最常见情况一步步说明。
sudo apt update
sudo apt install snapd -y
sudo snap install postman
启动:
postman
或直接在应用菜单搜索 Postman
cd ~/Downloads
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
tar -xzf postman.tar.gz
sudo mv Postman /opt/Postman
sudo ln -s /opt/Postman/Postman /usr/local/bin/postman
运行:
postman
示例(GET 请求):
Method: GET
URL: https://api.github.com/users/octocat
点击 Send
Method: POST
URL: http://localhost:8080/api/login
在 Body 标签:
rawJSON{
"username": "admin",
"password": "123456"
}
点击 Send
例如:
Key: Authorization
Value: Bearer your_token
curl -X GET https://api.github.com/users/octocat
POST + JSON:
curl -X POST http://localhost:8080/api/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"123456"}'
安装:
sudo apt install nodejs npm -y
sudo npm install -g newman
运行 Postman 导出的集合:
newman run example.postman_collection.json
sudo apt install libnss3 libnotify4 libxss1 -y
0.0.0.0 而非 127.0.0.1如果你愿意,可以告诉我:
我可以直接给你 具体示例配置。