Handle if not matching request

67 views
Skip to first unread message

Tam Huynh Thanh

unread,
Jul 13, 2021, 1:08:59 AM7/13/21
to wiremock-user
I am going to have multiple case with same request but  differ request body, and I want if any request is not matching request body in any case, it will return a response that I definded
How I can do this?

Tom Akehurst

unread,
Jul 13, 2021, 9:37:03 AM7/13/21
to wiremock-user
The way to do this is to define two stubs: 1) with the specific URL, method and request body matchers for the positive response, 2) lower priority (> 5) with no body matchers for the fallback response.

The 1st, higher priority stub will be matched if URL, method and body are correct and you'll get that response. Otherwise it'll fall through to the 2nd stub and you'll get the response from that.

Reply all
Reply to author
Forward
0 new messages