【问题标题】:Query Parameter is not getting matched when using WireMock使用 WireMock 时查询参数不匹配
【发布时间】:2019-12-04 12:34:41
【问题描述】:

我正在尝试使用以下存根访问 WireMock,但查询参数似乎没有匹配。回复如下:

                                               Request was not matched
                                               =======================

-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           |
GET                                                        | GET
/mpp-pricing/v1/agreements\?accountId=.*                   | /mpp-pricing/v1/agreements?accountId=5388afaf-ee3d-44ed-a<<<<< URL does not match. When using a regex, "?" should be "\\?"
                                                           | b2a-0035156bb0a2
                                                           |

这是我使用的存根:

{
  "request": {
    "method": "GET",
    "urlPathPattern": "/mpp-pricing/v1/agreements\\?accountId=.*"
  },

【问题讨论】:

    标签: wiremock http-request-parameters wiremock-standalone


    【解决方案1】:

    我自己也遇到过同样的问题,但我能够通过使用 queryParameters 重写匹配器来克服。

    也许您可以做类似的事情并重新编写您的模式,如下所示:

    {
        "request": {
            "method": "GET",
            "urlPathPattern": "/mpp-pricing/v1/agreements",
            "queryParameters": {
               "accountId": {
                  "matches": ".*"
               }
            }
        }
    },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-29
      • 2017-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多