请求正文参数的 Postman Mock Server 匹配算法逻辑 [英] Postman Mock Server matching algorithm logic for request body param
问题描述
以下 API URL 有两种方案.
I have two scenarios for the following API URL.
POST http://{{ip_port}}/oauth/token
POST http://{{ip_port}}/oauth/token
当我输入正确的用户名和密码时,它应该返回200 和模拟 json 响应.
When I put the user name and password correctly, it should return 200 and mock json response.
当我输入错误的用户名和密码时,它应该返回401并模拟json(错误).
When I put user name and password incorrectly, it should return 401 and mocked json(error).
在Postman
Mock server中,发现request param没有匹配的算法逻辑.
In Postman
Mock server, I noticed that there is no matching algorithm logic for request param.
我想按请求参数过滤并返回相关的模拟响应.我不想为上述场景添加两个 URL(/token 和/failedtoken)
.
I want to filter by request param and return related mock responses. I don't want to add two URLs(/token and /failedtoken)
for above scenarios.
目前Postman只支持三种逻辑匹配算法逻辑.
Currently Postman only support three logic for matching algorithm logic.
- 格式正确的回复
- HTTP 方法
- 按网址过滤
Postman Mock Server 有没有办法为多个场景只添加一个 URL?
Is there any way to add only one URL for many scenarios in Postman Mock Server?
推荐答案
Postman Mock Server 现在支持按请求正文匹配.您可以通过指定自定义标头来使用它(x-mock-match-request-body
到 true
).
Postman Mock Server now supports matching by request body. You can use it by specifying a custom header (x-mock-match-request-body
to true
).
您还可以通过转到 New->Templates
并搜索 Request Body Matching
来查看演示此功能如何工作的示例.
You can also check out an example that demonstrates how this feature works by going to New->Templates
and searching for Request Body Matching
.
这篇关于请求正文参数的 Postman Mock Server 匹配算法逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!