I am using wiremock-jre8-standalone-2.35.0.jar
This is my mapping file -
{
"request": {
"urlPattern": "/fulfillmentstate\\?fulfillmentid=SVT-ETA-\\d+(%2CSVT-ETA-\\d+)*",
"method": "GET",
"queryParameters" : {
"fulfillmentid" : {
"matches" : "^SVT-ETA-\\d+(,SVT-ETA-\\d+)*$"
}
}
},
"response": {
"status": 200,
"fixedDelayMilliseconds": 500,
"transformers": [
"response-template"
],
"headers": {
"Content-Type": "application/json"
},
"bodyFileName": "fulfillmentstate_qpm.json"
}
}
The URL I am hitting via postman -
http://localhost:8080/fulfillmentstate?fulfillmentid=SVT-ETA-1234%2CSVT-ETA-234%2CSVT-ETA-344
Now Response Templating that I have used in fulfillmentstate_qpm.json is -
{{request.query.fulfillmentid.[0]}}
Expected : SVT-ETA-1234 Actual : SVT-ETA-1234,SVT-ETA-234,SVT-ETA-344
This is the official documentation : https://wiremock.org/docs/response-templating/ (Under heading The Request Model)
I need to use these query parameter in a response file where I need to add multiple json attribute for each query parameter.
I have tried {{request.query.fulfillmentid.[0]}} {{request.requestLine.query.fulfillmentid.[0]}}
This is an Alternative : if the Request URL is :
here the URL have query parameter separated by comma, to access each element by index is :
Above expression will respectively produce