Cork Kochi
Cork Kochi

Reputation: 1891

Wiremock request matching for dynamic values

The sample JSON I use for stub

 {
  "request": {
    ...
    "bodyPatterns" : [ {
      "equalToJson" : "{ \"id\": abc123  }",
      "ignoreArrayOrder" : true,
      "ignoreExtraElements" : true
    } ]
    ...
  },

here the id is a dynamic value, so in this case, how can I do the request matching in wire mock

Upvotes: 0

Views: 1344

Answers (1)

Tom
Tom

Reputation: 4149

You can use a wildcard to match any value of id:

"bodyPatterns" : [ {
      "equalToJson" : "{ \"id\": \"${json-unit.any-string}\"  }",
      "ignoreArrayOrder" : true,
      "ignoreExtraElements" : true
    } ]

Upvotes: 3

Related Questions