请求正文参数的 Postman Mock Server 匹配算法逻辑

编程入门 行业动态 更新时间:2024-10-27 18:28:07
本文介绍了请求正文参数的 Postman Mock Server 匹配算法逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下 API URL 有两种方案.

I have two scenarios for the following API URL.

POST {{ip_port}}/oauth/token

POST {{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 匹配算法逻辑

    本文发布于:2023-10-29 09:32:05,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1539344.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:算法   逻辑   参数   正文   Mock

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!