2

Suppose I have endpoint: /url?number="321"&name="TEST" but when we are matching a request matching how we want to ignore the order of query parameter(ignore order of query param)

In this case if pass query param in query param tag then I will not distinguish between request, because same endpoint but multiple query param.

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
Piyush Garg
  • 37
  • 2
  • 10

1 Answers1

1

In the documentation the section on Regular Expression shows the example for matching on Query Parameters. It is even possible to include the absence of a parameter.

Using your example it might look like:

{
  "request" : {
    "urlPath" : "/url",
    "method" : "GET",
    "queryParameters" : {
      "number" : {
        "equalTo" : "321"
      },
      "name" : {
        "equalTo" : "TEST"
      }
    }
  },
  "response" : {
    "status" : 200
  }
} 
A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
  • It might be helpful to also include that the URL Matching documentation recommends matching on path only if you want to achieve matching on query parameters in an order invariant manner. http://wiremock.org/docs/request-matching/#url-matching – agoff Aug 31 '20 at 14:28
  • In Above example if any other query param is coming so how we can ignore in our stub like In post request ignore the other key and value pair in payload – Piyush Garg Sep 09 '20 at 17:10