Switch protocol during scenario

I have need to access different APIs and web UI during scenario. I can see there is a way to add multiple protocols on setUp:
setUp(…).protocols(httpProtocol, anotherHttpProtocol)

But don’t see how to choose which protocol will be used for request execution:
scenario(…).exec(http(…)…)

Is there a way to do so? Thanks.

Not possible. You need 2 different scenarios, possibly coordinated with andThen.

thank you! To do this I’ve tried following:

   setUp(
        scenario_1.inject(atOnceUsers(1)).protocols(httpProtocol1)
          .andThen(
              scenario_2.inject(atOnceUsers(1)).protocols(httpProtocol2)
          )
    )

and got compilation error:
type mismatch;
found : io.gatling.core.structure.PopulationBuilder
required: io.gatling.commons.validation.Validation[io.gatling.core.structure.PopulationBuilder] => ?
scenario_2.inject(atOnceUsers(1)).protocols(httpProtocol2)

did I do wrong?

Probably using an old Gatling version from before andThen was introduced.

Kind reminder: How to Ask a Question

Use Up-to-Date Versions

Please make sure to use the latest version of Gatling, in particular if you think you’ve found a bug.
This bug might have already been fixed. Gatling developers won’t have time to dig into old versions.

Thank you for your time and your kind answers.

You were right, gatling version was quite old. Checking with the latest one.