Postman Mock Server 请求体参数匹配算法逻辑

Postman Mock Server matching algorithm logic for request body param

我有以下两种情况 API URL。

POST http://{{ip_port}}/oauth/token

  1. 当我输入正确的用户名和密码后,应该return 200 和模拟 json 响应。

  2. 当我输入错误的用户名和密码时,它应该 return 401 并模拟 json(错误)。

Postman模拟服务器中,我注意到请求参数没有匹配算法逻辑。

我想按请求参数和 return 相关的模拟响应进行过滤。我不想为上述情况添加两个 URLs(/token and /failedtoken)

目前Postman匹配算法逻辑只支持三种逻辑

  1. 格式正确的回复
  2. HTTP 方法
  3. 过滤 URL

有没有什么办法可以在Postman Mock Server中很多场景只加一个URL?

邮递员模拟服务器 now supports matching by request body。您可以通过指定自定义 header(x-mock-match-request-bodytrue)来使用它。

您还可以通过转至 New->Templates 并搜索 Request Body Matching.

查看演示此功能如何工作的示例