温馨提示×

ubuntu下postman如何导出结果

小樊
48
2026-10-15 16:35:00
栏目: 智能运维

在 Ubuntu 下使用 Postman 导出“结果”,通常分几种常见场景。下面按最常见需求给你说明:


一、导出接口请求(Request / Collection)

如果你是想把接口或整个集合导出来:

1. 导出单个请求

  1. 打开该请求
  2. 点击右上角 ···(更多)
  3. 选择 Export
  4. 选择格式(推荐 Collection v2.1)
  5. 保存到本地(如 /home/user/xxx.json)

2. 导出整个 Collection

  1. 左侧选择 Collection
  2. 点击 ···
  3. 选择 Export
  4. 选择版本后导出 JSON

二、导出“测试结果”(Test Result)

Postman 的 Test Results 面板不能直接导出 GUI 文件,但可以用以下方式:

方法 1:用 console.log 输出并复制

在 Tests 中写:

console.log(JSON.stringify(pm.response.json()));

然后在:

View → Show Postman Console

复制输出内容。

方法 2:Newman(推荐,最规范)

如果你用 Collection Runner 跑测试:

sudo npm install -g newman
newman run your_collection.json -r cli,json

导出 JSON 报告:

newman run your_collection.json -r json --reporter-json-export result.json

三、导出响应数据(Response)

如果你只是想保存接口返回内容:

  1. 发送请求
  2. 在 Response 区域
  3. 点击 Save Response → Save to file
  4. 选择 Ubuntu 本地路径

四、导出环境变量 / 全局变量

  1. 右上角 Environments
  2. 选择环境
  3. 点击 Export
  4. 得到 .json 文件

总结

需求 方法
接口定义 Export Collection
测试结果 Newman 导出 JSON
返回数据 Save Response to file
环境变量 Export Environment

如果你能说清楚你是**“导出什么结果”**(测试报告 / 返回数据 / 接口文件),我可以给你更精确的命令或截图级步骤。

0 踩