Second request is getting failing with 403 error


I am using below code with “noOfPrints” value ‘1’ , which works fine:

defprintAndVerifyCompleteStatus(noOfPrints: Int,waitAfterPrintJobs: Int):ScenarioBuilder= scenario(“Basic Print”)

.exec(session =>session.set(“id”,session.userId))

.repeat(noOfPrints) {

exec(GatlingIIDPrinterService.getPrinterStatus(“Get printer status”, “${id}”).check(jsonPath("$[0].printer.printerStatus").saveAs(“printerStatus”)))




Now if i am using “noOfPrints” value more than 1 then First request is passing and second is failing with 403 error, stating that could not verify scrf token because session was not found.

Are you referring to CSRF token rather than SCRF? If CSRF token is the issue for causing the 403 response code, then the first request should not be passing or otherwise, you need to capture the CSRF token by visiting the site first and perform .check(regex()).saveas(), refer to Gatling Open-Source Load Testing Documentation – For DevOps and CI/CD.

Won’t be able to look into what exactly is the issue unless a full functioning sample has been provided.

Output of the report is showing OK=1 and KO=1, where 1st request is passing and 2nd request is showing 403 error. And there is no way of fetching the csrf token in application because it is coming from application’s backend so i am using config file to add the csrf token manually then adding it to the header of the request.