Read http protocol config from JSON file

Hi All,

I am trying to create a framework for my performance test. I am able to run the POST/PUT api successfully by reading the body from a JSON file.
I also want to read the HTTP protocol configuration from JSON file instead of hardcoding it in the scala file. I am not able to do the same.

Has anyone tried to do this? please share your experience.

Example:

val httpProtocol = http
.baseUrl(“https://example.com”)
.acceptHeader(“application/json; v=1.5”)
.authorizationHeader(“bearer bearer token here”)

I want the above protocol properties to be read from JSON file instead of hard coding here.
I am reading JSON file in my POST/PUT calls using below code

def postCase1api()={
exec(
http(“post case”)
.post("/api/case1")
.body(ElFileBody(“resources/data/apicase.json”)).asJson
)

}

That’s an inception problem: you’re trying to configure a Gatling simulation with Gatling itself. That’s not possible.
You can populate your protocol from a call to a remote REST API, but you can’t use the Gatling DSL for that. You have to use an HTTP client library (java.net.URLConnection, OkHttp, etc).