0

I'm currently trying to customize the Status code in a WireMock mapping.

I want to do something similar to this.

"response" : {
      "status" :"{{#if true}}200{{/if}}{{else}} 204 {{/if}}",
      ...
      ...
      ...
  }

When doing so, I get the following error.

Cannot deserialize value of type `int` from String "{{#if true}}200{{/if}}{{else}} Not found {{/if}}": not a valid `int`

Is it possible to use the response templating syntax in the status code field? if not, is there a way to customize the response of this field?

user3799465
  • 1
  • 1
  • 2

1 Answers1

0

It's not possible to template the status code at present (current version = 2.33.2).

Instead you need to create two or more stubs with different statuses and varying match criteria.

Tom
  • 3,471
  • 21
  • 14
  • Thanks, @Tom for your answer. In my case writing two stubs won't solve my problem, as the URL I'm trying to mock contained a base 64 id which changes from one call to another. I need to decode it, parse it, then decide based on its content to either return a 200 code with some content or a 204 response code with an empty body. – user3799465 Jun 09 '22 at 07:10