温馨提示×

debian Postman怎么发请求

小樊
39
2026-10-10 15:20:18
栏目: 智能运维

在 Debian 上使用 Postman 发送 HTTP 请求,一般有 两种方式:
1️⃣ 安装 Postman 桌面版(推荐)
2️⃣ 使用 Postman CLI(newman) 或通过命令行模拟(curl)

下面我按最常见情况一步步说明。


一、在 Debian 上安装 Postman(桌面版)

方法 1:通过 Snap(最简单)

sudo apt update
sudo apt install snapd -y
sudo snap install postman

启动:

postman

或直接在应用菜单搜索 Postman


方法 2:下载官方压缩包(无 snap 时)

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

二、用 Postman 发请求(基本操作)

1️⃣ 创建请求

  • 打开 Postman
  • 点击 “+” 或 New → HTTP Request

2️⃣ 填写请求信息

示例(GET 请求):

Method: GET
URL: https://api.github.com/users/octocat

点击 Send


3️⃣ 发送 POST 请求(常见)

Method: POST
URL: http://localhost:8080/api/login

在 Body 标签:

  • 选择 raw
  • 类型选 JSON
{
  "username": "admin",
  "password": "123456"
}

点击 Send


4️⃣ 添加 Headers

例如:

Key: Authorization
Value: Bearer your_token

三、在 Debian 命令行发请求(替代方案)

✅ curl(最常用)

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"}'

✅ newman(Postman 命令行版)

安装:

sudo apt install nodejs npm -y
sudo npm install -g newman

运行 Postman 导出的集合:

newman run example.postman_collection.json

四、常见问题

❓ Debian 打不开 Postman

sudo apt install libnss3 libnotify4 libxss1 -y

❓ 局域网请求不通

  • 检查防火墙
  • 确认服务监听 0.0.0.0 而非 127.0.0.1

如果你愿意,可以告诉我:

  • 你是 桌面 Postman 还是服务器无界面
  • 发的是 GET / POST / WebSocket
  • 请求的是 本地服务还是公网 API

我可以直接给你 具体示例配置。

0 踩