Closed pouyaSobhanipour closed 1 year ago
So depending on a random value from a string list, you want to return a different message and a random code?
Hello .
I need to pass a value into the Random string list. as an example
String List: "{{Random Type=\"StringList\"
Values=[\"{'result':'ERROR','description':'Value Not Found','ReqCode':'{{ my random Code }}'}\",
\"{'result':'ERROR','description':'Value set to Null','ReqCode':'{{my random Code }}'}\",
\"{'result':'ERROR','description':'More than one item','ReqCode':'{{my random Code }}'}\"
]}}"
so my request body would be (using a Post request) :
{
'ReqCode':'1234'
}
and the response would be a random string, chosed from the Random List filed with the passed data. so the response body comming from wiremock server would be:
{'result':'ERROR','description':'Value set to Null','ReqCode':'1234'}
How am i able to implement this ?
Thanks
Hello
i am using Random HandleBar in .Net to receieve a randome response from a list of predefied values using wiremock.
String List: "{{Random Type=\"StringList\" Values=[\"a\", \"b\", \"c\"]}}"
in my case a, b or c are different json responces. as following :a => {\'result\':\'ERROR\',\'description\':\'Value Not Found\',\'ReqCode\':\'123\'} b => {\'result\':\'ERROR\',\'description\':\'Value set to Null\',\'ReqCode\':\'456\'} c => {\'result\':\'ERROR\',\'description\':\'More than one item\',\'ReqCode\':\'789\'}
what i need to have in my project , is to understand which response ( a , b or c ) is associated with what request ( but i don't want the ReqCode to be fixed and pre-defiend).
we already know that one way to pass a dynamic value from request into response would be using "Response Templating - {{ }}" . but in this case , i could not find a way to pass this dynamic value using Random responce handlebar as the following :
\"a\ => "{\'result\':\'ERROR\',\'description\':\'Value Not Found\',\'ReqCode\':\'{{ my random Code }}\'} \"b\ => "{\'result\':\'ERROR\',\'description\':\'Value set to Null\',\'ReqCode\':\'{{my random Code }}\'} \"c\ => "{\'result\':\'ERROR\',\'description\':\'More than one item\',\'ReqCode\':\'{{my random Code }}\'}
using this what i receive in response is the string itself ({{my random Code }}) rather than the value i passed in request body. Is there any way to do this in wiremock ?
Thanks