wiremock / wiremock-webhooks-extension

Webhook simulation for WireMock
Apache License 2.0
24 stars 11 forks source link

How to change new request body in standalone mode via json configuration #16

Open wbulba opened 4 years ago

wbulba commented 4 years ago

this is my template

{ "request": { "method": "POST", "url": "/api/mytestingwebhooksextension" }, "response": { "status": 200, "body": "{\"id\":\"{{jsonPath request.body '$.Object.id'}}, \"udid\":\"{{randomValue type='UUID'}}\"}\"" }, "postServeActions" : { "webhook" : { "headers" : { "Content-Type" : "application/json" }, "method" : "POST", "body" : "{\"id\":\"{{jsonPath request.body '$.Object.id'}}, \"udid\":\"{{randomValue type='UUID'}}\"}\"", "url" : "http://127.0.0.1:8081/api/mytest" } } }

i am run standalone wiremock with option --global-response-templating

this section is transform well for response, but not transform for request body": "{\"id\":\"{{jsonPath request.body '$.Object.id'}}, \"udid\":\"{{randomValue type='UUID'}}\"}\""

in response i see {"id":"17, "udid":"7d138e9b-efb5-4704-8248-98e34fdbc51d"}"

but in sending request i see "{"id":"{{jsonPath request.body '$.Object.id'}}, "udid":"{{randomValue type='UUID'}}"}"

VorobeyEugene commented 3 years ago

I'm also interested to know.

tomakehurst commented 3 years ago

I've been working on a new version of the webhooks extension. It's nearly ready to be released and supports delays, templating, multiple webhooks and runs standalone.

The docs are here if you'd like a quick look: https://github.com/tomakehurst/wiremock/blob/webhooks-core-extension/docs-v2/_docs/webhooks-and-callbacks.md