Accessing saved json respose

Hello,

I was trying to access and set variable saved from session, but unable to do so. Representative anonymized json has been attached. Have multiple such elements in that.

Saving the complete json response as Json object and all entries.id using below

.check(jsonPath("$.entries[*]").ofType[Any].transform(mapToJson).findAll.saveAs(“DCategory”))

.check(jsonPath("$.entries[*].id").findAll.saveAs(“EntriesId”)))

Getting Random entries.id using following for use in further requests

.exec(session => {
session(“EntriesId”).validate[Seq[String]] match {
case Success(ids) =>
val index = ThreadLocalRandom.current.nextInt(ids.size)
session.set(“EntriesIdSelect”, ids(index))
case _ => session
}
})

After this wanted to get $…Tuple4.id only if its parent entries.id matches above randomly selected entries.id, so tried to do following

.exec(session => {
session(“EntriesId”).validate[Seq[String]] match {
case Success(ids) =>
val index = ThreadLocalRandom.current.nextInt(ids.size)
session.set(“EntriesIdSelect”, ids(index)).set(“SelectTuple4Id”, “”"(${DCategory}.entries[].videos[?(@${DCategory}.entries[].id==’${EntriesIdSelect}’)].id).toString""")

case _ => session
}
})

But the ${DCategory}.entries[].videos[?(@${DCategory}.entries[].id==’${EntriesIdSelect}’)].id).toString is not evaluated and replaced with actual Tuple4 id. Anything missing?

Thanks in advance.

sample_json.txt (668 Bytes)