How to call a request like a function or module

Hi,

I am building a script that i want to call a same request in different groups. but every time parameter might be different. So i have something like this.

object a {
val scn = group(“A”) {
exec(http 1 …)…
.exec(_.set(“name”), “value1”)
R.req
}
}

object b {
val scn = group(“B”) {
exec(http 2)…
.exec(_.set(“name”), “value2”)

R.req
}
}

object R {
val req = exec…${name}
}

it seems like once the script get into group A, it won’t execute the first exec http1, but rather go R.req directly. So the session attribute set is not executed, then R.req reported no attribute called “name” was found.

Any ideas? or there is a better way of doing this?

Any help is appreciated. :slight_smile:

R.req isn’t attached to the first chain, and is the last instruction so only it is passed to the groups.

.exec(R.req)

Thanks for the quick reply! .exec(R.req) works perfect!