I want to extract an attribute's value from JSON request body coming in a request in a running standalone wiremock server and use the value in the response. Is there any way to this dynamically.
For example, if below is the request body :
{
"name": "Dummy-Name"
}
I should be able to extract the value of name
attribute and send it in the response like below:
{"Request_Name": "Dummy-Name"}
CodePudding user response:
You can use the Request model and JsonPath helpers to achieve this.
...
"response": {
"body": "{ "Request_Name": {{jsonPath request.body '$.name'}} }"
}
...
Note: you will need to enable response templating before this will work.