Carlos Villar
09/12/2023, 2:53 PM{
"request": {
"method": "POST",
"url": "/api/endpoint"
},
"response": {
"status": 200,
"transformers": [
"response-template"
],
"bodyFileName": "response.json",
"headers": {
"Content-Type": "application/json"
}
}
}
response.json
{
"message": "Hello, {{request.body.message}}!",
"status": 200
}
I need this response:
{
"message": "Hello, Carlos!",
"status": 200
}
but I get this:
{
"message": "Hello, {{request.body.message}}!",
"status": 200
}
request body:
{
"message": "Carlos"
}
What's wrong? Is it possible?
wiremock standalone 3.0.1
java -jar wiremock-standalone-3.0.1.jar --port 8282 --verbose
Linux server
Thanks a lot!!Tom
09/12/2023, 3:01 PM--local-response-templating
to your startup paramsCarlos Villar
09/12/2023, 3:13 PM{{request.body.message}}
Aaron
09/12/2023, 3:27 PM{{request.body.foo}}
isn’t recommended ->
https://wiremock.org/docs/response-templating/#the-request-model
Instead, we’ll need to use the JSON helpers to make this a little easier. https://wiremock.org/docs/response-templating/#jsonpath-helper Something like the following should work:- Request body text (avoid for non-text bodies)request.body
{{jsonPath request.body '$.message'}}
Carlos Villar
09/12/2023, 3:36 PM