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

**URL:** <https://community.gatling.io/t/error-duplicate-key-class-io-gatling-http-protocol-httpprotocol-using-2-different-protocols/8419>\
**Category:** Gatling (Open-Source)\
**Created:** [November 2, 2023, 1:56pm UTC](https://community.gatling.io/t/error-duplicate-key-class-io-gatling-http-protocol-httpprotocol-using-2-different-protocols/8419 "2023-11-02T13:56:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nebula](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@nebula](https://community.gatling.io/u/nebula)\
**Post date:** [November 2, 2023, 1:56pm UTC](https://community.gatling.io/t/error-duplicate-key-class-io-gatling-http-protocol-httpprotocol-using-2-different-protocols/8419/1 "2023-11-02T13:56:01Z")

</div>

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`

```scala
setUp(
                    scn1.injectOpen(atOnceUsers(1))            
        ).protocols(protocol1, protocol2)

```

And the protocols are defined as:

**Protocol 1**

```scala
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**

```scala
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

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [November 2, 2023, 5:24pm UTC](https://community.gatling.io/t/error-duplicate-key-class-io-gatling-http-protocol-httpprotocol-using-2-different-protocols/8419/2 "2023-11-02T17:24:12Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![nebula](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@nebula](https://community.gatling.io/u/nebula)\
**Post date:** [November 3, 2023, 12:48pm UTC](https://community.gatling.io/t/error-duplicate-key-class-io-gatling-http-protocol-httpprotocol-using-2-different-protocols/8419/3 "2023-11-03T12:48:42Z")

</div>

Thks!  
Keep that in mind for next time

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [December 3, 2023, 12:48pm UTC](https://community.gatling.io/t/error-duplicate-key-class-io-gatling-http-protocol-httpprotocol-using-2-different-protocols/8419/4 "2023-12-03T12:48:58Z")

</div>

Closed on December 3, 2023, 12:48pm UTC

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