Hi,
I’m unable to understand this behavior. I have tried to elucidate my code below. Value of session(“UserId”).as[String] and EL ${UserId} differ in same execution chain for same session.
What am i missing to tis this. Body and Header of HTTP Request should have same value but they differ in actual request.
Please note that when i do single user run, the test passes (return 200 K), but for multiple users I get the issue below (400 fail):
{
“error_msg”:”userId in header 123146529326857 does not match userId in body 123146529341992”
}
Thank you in advance for any guidance
Thanks
shree
//scenario class
val callChain=scenario(“TestScenario")
.exec(api.Login.LoginTransaction)
.exec(api.apiCreateEntity.apiCreateEntityTransaction)
//api.Login class
val apiLoginTransaction =
exec(
http(“Login”)
…
…
.check(jsonPath("$.ticket").saveAs(“TickeId"))
.check(jsonPath("$.userId").saveAs(“UserId”))
//api.apiCreateEntity class
var Payload=
“”"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<userCredentials xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:type=“MyCredential">
%%AUTH_ID1%%
<owner xsi:type=“MyCredentialKey" xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
%%AUTH_ID2%%
“”"
val apiCreateEntityTransaction =
.exec(session => {
val userId=session(“UserId”).as[String] // WHY IS DIFFERENT FROM EL EXPRESSION USED IN HEADER FOR ${USERID} BELOW IN HTTP REQUEST SUBMITTED??
var ticketId=session(“TicketId”).as[String]
Payload=Payload.replace("%%AUTH_ID1%%”,userId)
Payload=Payload.replace("%%AUTH_ID2%%”,userId)
})
.exec(
http(“CreateEntity”)
.post(“some url”)
.header(“Authorization”, “Some_Authentication token,userId=${UserId}”)
.header(“Content-Type”, “application/xml”)
.body(StringBody("${Payload}")
Results
response:
status 400
{
“error_msg”:"userId in header 123146529326857 does not match userId in body 123146529341992”
}
HTTP Trace
“Authorization”, “Some_Authentication token,userId=123146529326857”
compositeByteData=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<userCredentials xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:type=“MyCredential">
123146529326992
<owner xsi:type=“MyCredentialKey" xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
123146529326992