Hi everyone.
I am facing a problem which I can’t seem to solve. I have tried all sorts of ways to approach this, but nothing seems to work.
I have a method to perform a POST call:
`
def postCall(id: String, entries: List[Map[String, String]]): ChainBuilder = exec(
http(“POST”)
.post("/" + id)
.header(“Authorization”, “x”)
.header(“Content-Type”, “application/json”)
.body(StringBody(mapper.writeValueAsString(Map(“resources” → entries)))).asJSON
.check(status.is(207)))
`
In my main scenario, I am gathering a bunch of resources, which I am saving in the session under “resources” as List[Map[String, String]]. At the end of the scenario, I want to pass this List to the method above to perform a POST request.
However, I am having trouble to retrieving the List as a List from the session object in order to pass it down.
The part where I call the method looks simplified something like one of these:
Problem: Method signature asks for List, but we have a “String”.
`
private val BatchDelete = scenario(“POST RESOURCES”)
.exec(postCall("${id}", “${resources}”))
`
Problem: The http request does not get executed
`
private val BatchDelete = scenario(“POST RESOURCES”)
.exec(session => {
postCall(session(“id”).as[String], session(“resources”).as[List[Map[String, String]]])
session
})
`
Same with:
`
private val BatchDelete = scenario(“POST RESOURCES”)
.exec(session => {
exec(postCall(session(“id”).as[String], session(“resources”).as[List[Map[String, String]]]))
session
})
`
Any ideas how to call postColl in my scenario with reading a List from the session? I am really desperate by now!
-Marvin