In wiremock json how to reuse the same random UUID in both response and callback

38 views Asked by At

i am trying to generate a random- uuid and use it in response as well as in serveEventListeners. But it is not working. Can someone help out?

This is the command used to start the wiremock:

docker run -it --rm -p 8080:8080 --name wiremock wiremock/wiremock:3.3.1 --verbose --global-response-templating

My mapping:

{
"request": {
    "method": "POST",
    "urlPattern": {{url_match_pattern}}
},
"response": {
    "status": 200,
    "headers": {
        "Content-Type": "application/json"
    },
    "jsonBody": {
        "request_id": "{{#assign 'ID'}}{{randomValue type='UUID'}}{{/assign}}{{ID}}"
    }
},
"serveEventListeners": [
    {
        "name": "webhook",
        "parameters": {
            "method": "POST",
            "url": "{{jsonPath originalRequest.query '$.callback_url'}}/{{request_id_two_str}}",
            "body": "{{ID}}",
            "delay": {
                "type": "fixed",
                "milliseconds": 5000
            },
            "headers": {
                "Content-Type": "application/json"
            }
        }
    }
]

}

i am setting the variable "ID" in response and using it in serveEventListeners. If this does not work, is there any other way out in json?

If not possible in json, how to do this in java?

0

There are 0 answers