hi all, i am trying to generate a random uui as pa...
# general
v
hi all, i am trying to generate a random uui as part of the response:
Copy code
{
    "request": {
        "method": "POST",
        "urlPattern": {{url_match_pattern}}
    },
    "response": {
        "status": 200,
        "jsonBody": {
            "request_id": "{{#assign 'ID'}}{{randomValue type='UUID'}}{{/assign}}{{ID}}"
        },
        "headers": {
            "Content-Type": "application/json"
        }
    }
}
But i receive the following as json :
Copy code
{
  "request_id": "{{#assign 'ID'}}{{randomValue type='UUID'}}{{/assign}}{{ID}}"
}
May i know what is wrong here ?
l
Hi, is there a reason you are trying to assign the random UUID to a variable ? You should be able to do the following:
Copy code
"jsonBody": {
  "request_id": "{{randomValue type='UUID'}}"
}
Which should generate something like:
Copy code
{
  "request_id": "cacee46c-c612-4372-9477-652524d1bbda"
}
v
thanks. But received the following in the response rather than the random uuid:
Copy code
{
  "request_id": "{{randomValue type='UUID'}}"
}
And the logs of wiremock is attached below
My mappings json:
Copy code
{
    "request": {
        "method": "POST",
        "urlPattern": {{url_match_pattern}}
    },
    "response": {
        "status": 200,
        "jsonBody": {
            "request_id": "{{randomValue type='UUID'}}"
        },
        "headers": {
            "Content-Type": "application/json"
        }
    }
}
i got it.. it got fixed by adding response-templating.
docker run -it --rm -p 8080:8080 --name wiremock wiremock/wiremock:3.3.1 --verbose --global-response-templating
l
Awesome, that was going to be my next suggestion 😀 There are also newer versions now with some nice improvements if you are able to upgrade https://wiremock.org/docs/standalone/docker/#getting-started