https://linen.dev logo
#help
Title
# help
b

Bas Dijkstra

03/08/2024, 9:30 AM
So, I'm writing a mock definition in JSON (for a standalone WireMock instance), and I'm looking to use response templating to echo the value of an element
quantity
from the request body in a response. Using
"quantity": "{{jsonPath request.body '$.quantity'}}"
it works, but that converts the element in the response to a string, not an integer. If I remove the double quotes, WireMock tells me my JSON is invalid. How can I easily return request body integer values as an integer in the response?
l

Lee Turner

03/08/2024, 9:54 AM
Are you using
jsonBody
to return your response body? If so you might have to change that to
body
b

Bas Dijkstra

03/08/2024, 10:13 AM
That works, thanks @Lee Turner. Ugly, but it does the trick for now.
🙌 1
l

Lee Turner

03/08/2024, 10:14 AM
Yeah, there isn't a nice way to do this with non string items as far as I know
b

Bas Dijkstra

03/08/2024, 10:17 AM
No worries, it's good to know. This one's 'only' for the purpose of having something to have a crack at in an API security testing workshop anyway
3 Views