wiremockhttp-request-parameterswiremock-standalone

Query Parameter is not getting matched when using WireMock


I am trying to hit the WireMock with following stub but it seems that the query param is not getting matched. Here is the response:

                                               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
                                                           |

and this is the stub I used:

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

Solution

  • I have faced the same issue myself but I was able to overcome by re-writing the matcher using queryParameters.

    Maybe you could do something similar and re-write your pattern as below:

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