I am using wiremock-standalone-3.4.2, trying to emulate a 3rd party that upon a request from me responds with a certain field with UUID value X and sends the same value X to a webhook. The value X needs to change from request to request so it needs to be randomized. I can't seem to find a way to have the emulator return in the response the same random value it send to the webhook. Any ideas?
Tried using {{randomValue type='UUID'}} in both places but this expectedly resulted in 2 different random values. -
{
"priority": 1,
"request": {
"method": "POST",
"urlPath": "/v1/businesses"
},
"response": {
"status": 200,
"jsonBody": {
"id": "{{randomValue type='UUID'}}"
}},
"serveEventListeners": [
{
"name": "webhook",
"parameters": {
"method": "POST",
"url": "http://some-url/",
"headers": {
"Content-Type": "application/json",
},
"body": "{\"id\": \"{{randomValue type='UUID'}}\"}"}}]}
Currently there is no way to do this natively WireMock. We do have a proposal to implement this exact thing but at the moment it hasn't been addressed. I think there are a number of ways to achieve this at the moment: