Hi ,
I’m very new user of Gatling trying to build a scenario with json feeder using stringbody
//JSON
`
[
{
“apiKey”: “1E39281B-FDC6-4BC7-9184-A6D8FBBF217A”,
“machine”: {
“ServiceId”: 2,
“ServerRoleId”: 4,
“EnvironmentId”: 4,
“NetworkId”: 2,
“HardwareProfileId”: 2,
“OperatingSystemId”: 1
}
},
{
“apiKey”: “98480B54-1282-460E-8159-15A97546CF56”,
“machine”: {
“ServiceId”: 2,
“ServerRoleId”: 3,
“EnvironmentId”: 4,
“NetworkId”: 1,
“HardwareProfileId”: 2,
“OperatingSystemId”: 2
}
}
]
`
this scenario creating request with null in the body
`
val scn = scenario(“Create Machine”)
.feed(jsonFile(“machines.json”))
.exec(http(“create machine”)
.post("/api/machinebuild")
.headers(Map(“Content-Type” → “application/javascript”,
“Authorization” → “”"${apiKey}"""))
.body(StringBody(""" ${machine} “”")).asJSON
)
setUp(scn.inject(atOnceUsers(2)).protocols(httpConf))
`
where as this scenario creating request with expected content in the body
`
val scn = scenario(“Create Machine”)
.feed(jsonFile(“machines.json”))
.exec(http(“create machine”)
.post("/api/machinebuild")
.headers(Map(“Content-Type” → “application/javascript”,
“Authorization” → “”" ${apiKey}"""))
.body(StringBody(""" { “ServiceId”: ${machine.ServiceId},
“ServerRoleId”: ${machine.ServerRoleId},
“EnvironmentId”: ${machine.EnvironmentId},
“NetworkId”: ${machine.NetworkId},
“HardwareProfileId”: ${machine.HardwareProfileId},
“OperatingSystemId”: ${machine.OperatingSystemId}
} “”"
)).asJSON
)
setUp(scn.inject(atOnceUsers(2)).protocols(httpConf))
`