在 Mock Server 中获取响应

17 Mar 2025 | 阅读 2 分钟

在这里,我们将讨论如何在 Postman 中以其他不同的格式获取响应,这非常容易。最常见的格式是 JSON。让我们看看如何以 JSON 格式获取响应。

  • 从 Postman 应用的 Header 部分的左上角,选择 New
Get the Response in Mock Server
  • 选择 Mock Server。
Get the Response in Mock Server
  • 选择 Mock server 后,将打开一个新面板。通过此面板,我们可以创建一个新请求。
Get the Response in Mock Server
  • Response Body 列中,不要编写纯文本,而是以 JSON 格式输入响应正文。

在这里,我们将编写关于不同员工的数据

将上面的 JSON 复制到 Response body 中。

Get the Response in Mock Server
  • 按 Next。现在,在下一个面板中,根据您的选择命名服务器。我给的是 'JSON Response'。
Get the Response in Mock Server
  • 点击 Create Mock Server 按钮。
Get the Response in Mock Server
  • 选择 Employee API,然后选择 JSON Response 环境。
Get the Response in Mock Server
  • 按下 send 并查看响应。
Get the Response in Mock Server

在这里,您默认可能会以 HTML 格式获取响应,请从下拉列表中将格式更改为 JSON,您将获得如上所示的响应。

类似地,我们可以使用不同的格式在 mock server 中获取响应。


下一个主题Postman API 简介