ERROR Duplicate key class io.gatling.http.protocol.HttpProtocol using 2 different protocols

Hello all!

I am trying to run the following scenario reading from a CSV file:

Given an endpoint1 from the API1 and an endpoint2 from the API2
Submit a request on the endpoint1 using the
fetch a output value from the endpoint1’s response
And then submit a request on endpoint2 using the output value fetched previously

The problem I have is I do not know how to use 2 different protocols:

  • I have tried: protocols(protocol1, protocol2) but I get the following error: Duplicate key class io.gatling.http.protocol.HttpProtocol
setUp(
                    scn1.injectOpen(atOnceUsers(1))            
        ).protocols(protocol1, protocol2)

And the protocols are defined as:

Protocol 1

HttpProtocolBuilder httpProtocol = http
                .baseUrl(URL1)
                .acceptHeader("application/json")
                .contentTypeHeader("application/json; charset=utf-8")
                .acceptLanguageHeader("en-GB,en-US;q=0.9,en;q=0.8")
                .authorizationHeader(BASIC_AUTH);

Protocol 2

HttpProtocolBuilder httpProtocol = http
                .baseUrl(URL2)
                .acceptHeader("application/json")
                .contentTypeHeader("application/json; charset=utf-8")
                .acceptLanguageHeader("en-GB,en-US;q=0.9,en;q=0.8")
                .authorizationHeader(BASIC_AUTH);

Any thoughts?
Kind Regards

Hi @nebula,

Indeed, in your sample, you are defining twice the “http” protocol.

Do you know that even if you provide a baseUrl and other default settings in the protocol, you can give an absolute URL to the different steps? And the different steps are executed in the same scenario, the session will be shared as well?

Cheers!

Thks!
Keep that in mind for next time

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.