4

我正在尝试使用以下存根访问 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=.*"
  },
4

1 回答 1

2

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

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

{
    "request": {
        "method": "GET",
        "urlPathPattern": "/mpp-pricing/v1/agreements",
        "queryParameters": {
           "accountId": {
              "matches": ".*"
           }
        }
    }
},
于 2019-12-17T16:41:42.433 回答