Hi Everyone
I am trying to create a class structure in Gatling, I am calling this class snippet below from another class. The actual API call is taken from a standalone script which is working and then I modified it a bit
to try to get it to work in a class. (the variables changed, and added the .formparam()
Any help you could give would be greatly appreciated, I am new to Gatling/Scala
// -----------------------------------------------------CLASS SNIPPET-----------------------------------------------------------------------------------------------------------------
package load
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class CreateUsersAPICall(myURL : String, accountNumber :String, emailAddress :String, password :String, AuthNum :String) {
//Print out values just for debugging purposes
println("")
println(“Entering Create User API Call Method”)
println("URL: "+ myURL)
println("username: "+accountNumber)
println("Email Addresss: "+emailAddress)
println("Password: "+password)
println(“AuthNum: “+AuthNum)
println(””)
val httpConf = http
.baseURL(myURL)
.acceptHeader("/")
.connection(“keep-alive”)
.contentTypeHeader(“application/json; charset=utf-8”)
.disableCaching
.extraInfoExtractor(extraInfo => List(extraInfo.request, extraInfo.response,extraInfo.session))
val userCreateAccount = exec(http(“Create_Account”)
.post("/planner_tools/v1/account_api/accounts")
.header(“Authorization”, “api_key fb55b02e964b66af32d0f9a21aaa8c26”)
.body(StringBody( “”"{
.formParam(“company”: “pent”,
.formParam(“companyUrl”: “www.pent.com”)
.formParam(“accountName”: “Automation”)
.formParam(“accountNumber”: accountNumber)
.formParam(“companyCountry”: “CA”)
.formParam(“companyAddressLine1”: “1 Main St”)
.formParam(“companyCity”: “Fredericton”)
.formParam(“companyState”: “New Brunswick”)
.formParam(“companyZip”: “E3A 5M3”)
.formParam(“sourceSystem”: “PlannerTools”)
.formParam(“adminContactFirstName”: “PerfTestUser”)
.formParam(“adminContactLastName”: “Admin”)
.formParam(“adminContactEmail”: emailAddress)
.formParam(“adminContactOfficePhone”: “67576575665”)
.formParam(“companyBillingContactSameAsAdminContact”: true)
.formParam(“billingContactFirstName”: “Admin”)
.formParam(“billingContactLastName”: “Admin”)
.formParam(“billingContactEmail”: emailAddress)
.formParam(“billingContactOfficePhone”: “5065062321”}""")).asJSON
.check(status.is(201)))
// ---------------------------------------------------------OUTPUT SNIPPET-------------------------------------------------------------------------------------------------------------
Simulation load.CreateUsersAPICall started…
Entering Create User API Call Method
URL: https://api-internal-Removed for Security
username: 1460658876
Email Addresss: cvencan+admin1460658876@gmail.com
Password: Password
AuthNum: api_key fb55b02e964b66af32d0f9a21aaa8c26