Issue in passing Session values in .body(RawFileBody("A"))

Hi All,

I am using the Gatling 3.5.1 versions and observed the following.

  1. I am posting a multipart form data request in Raw format to the server and when I enabled the log file, it is sent in Base64 format from Gatling. When I decoded it via base64 decoder online , I could see that the Correlated session values are not substituted and it is simply sent as such.

  2. When I tried to the do the same as above by importing this import io.gatling.core.body.RawFileBody , I am getting this error Can’t cast of type class java.lang.String into class io.gatling.core.body.ResourceAndCachedBytes.

Note: The substitution works fine with ElFilebody and StringBody but the server couldn’t accept those format.

Kindly Help on this.

Regards,
Aravind G

Hi,

No idea what you’re doing.
Please share some code, stacktraces, etc…

OK, you’re trying to do body(new RawFileBody(???)) while the documentation clearly states body(RawFileBody(???)) without the new.

Hi Stephane,

Thanks for the reply.
No, I am using only the .body(RawFileBody("??")).
Please find the detailed observation below with the code trace

  1. Scenario 1 ( Without import io.gatling.core.body.RawFileBody ) - Substitution of session values not happening

object A {

// First call from where I get the dynamic values and correlate it in the xml file given in request-bodies/xml

.exec(http(“A”)
.post(url + “/B”)
.headers(C)
.body(RawFileBody(“request-bodies/xml”))
.check(status.is(200)))

}

  1. Scenario 2 ( With import io.gatling.core.body.RawFileBody ) ( rest of the code trace remains the same)
    Result - Unable to trigger the second request and getting the error Can’t cast of type class java.lang.String into class io.gatling.core.body.ResourceAndCachedBytes.

I hope this will be helpful Stephane.

Note: The substitution works fine with ElFilebody and StringBody but the server couldn’t accept those format

Regards,
Aravind G

The whole point of RawFileBody is to be able to send a file as is, without any transformation. So it doesn’t support EL expressions.

Hi Stephane,

Thanks for the clarification. I thought of an workaround to replace the correlated values in the request file and replace it with the dynamic values by using some file operations before triggering the actual request.

Regards,
Aravind G