How to get value from a Map returned by Groovy Script in Request
In the groovy script step, i returned a Map type value as:
===========================
def serverSessionIdVal = "${java.util.UUID.randomUUID()}";
def clientSessionIdVal = "${java.util.UUID.randomUUID()}";
vars = [:]
vars["sid"] = serverSessionIdVal
vars["cid"] = clientSessionIdVal
return vars
===========================
In the REST Request body, we can use place holder "${DefineVars#result}" to access the whole map, while how can i access one of the value like vars["cid"]
Hi,
With the specific approach you have taken I am uncertain what syntax to use at this point. However, I would normally do what you hopefully want a slightly different way using the context map to hold your custom map:
def serverSessionIdVal = "${java.util.UUID.randomUUID()}"; def clientSessionIdVal = "${java.util.UUID.randomUUID()}"; vars = [:] vars["sid"] = serverSessionIdVal vars["cid"] = clientSessionIdVal context.vars=vars return vars
Then you can access the map values in a request with the following syntax:
${=vars.cid}
and
${=vars.sid}
Regards,
Rupert