Gatling 2.0.3 - Mapping values to template

178 views
Skip to first unread message

Murali Krishna

unread,
Aug 26, 2015, 7:20:21 AM8/26/15
to Gatling User Group
Hi All,

I am trying to Map values to the templete. I am testing web services. I need to populate response from the first rest call to another rest call as a request. I am doing in the below.

The RED color is the first POST call and I am saving the response into two values. Now I am passing the values to another POST call in YELLOW color.

I am getting the below error. Please help to solve this issue
too many arguments for method body: (bd:io.gatling.http.request.Body)io.gatling.http.request.builder.HttpRequestWithParamsBuilder


val authorization = scenario("Authorization")
  .feed(correlationIdFeeder) 
  .feed(dataFeeder) 
  .feed(csvFeeder)
  .exec(
    http("Creating tm token given an external token")
      .post(tokenization_endpoint)
      .body(ELFileBody("tokenization.json")).asJSON       
      .check(status.is(200))           
      .check(jsonPath("$.payment_token").saveAs("payment_token"))     
      .check(jsonPath("$.payment_transaction_id").saveAs("payment_transaction_id"))

     )
     .exec(
       http("Authorization flow")
      .post(authorization_endpoint)
      .body(ELFileBody("authorization.json"), Map("payment_token" -> "${payment_token}", "payment_transaction_id" -> "${payment_transaction_id}", "transaction_date" -> "${current_date}", "value" -> "${amount}"  ) ).asJSON    
      .check(status.is(200))      
      .check(jsonPath("$.transaction_details.transaction_status").is("Approved"))
      .check(jsonPath("$.transaction_details.transaction_status_code").is("0x20"))
      .check(jsonPath("$.transaction_details.payment_token").is("${payment_token}"))
      .check(jsonPath("$.transaction_details.payment_transaction_id").is("${payment_transaction_id}"))
      .check(jsonPath("$.transaction_details.transaction_date").is("${current_date}"))
     )

Thank You
Murali.

Abhinav Gogna

unread,
Aug 26, 2015, 3:46:32 PM8/26/15
to Gatling User Group
Error says it all. .body only takes one argument but you are passing two.

You can include all payment in the request body file. ElFilebody is used when you want to programmatically change parameters.

Murali Krishna

unread,
Aug 27, 2015, 1:25:16 AM8/27/15
to Gatling User Group
Can you share me how to write.

Abhinav Gogna

unread,
Aug 27, 2015, 12:13:23 PM8/27/15
to Gatling User Group
Sure

Here is an example

val scn = scenario("xxxx")
.feed(xxxEntryFeeder)
.exec(http("Submit JSON")
.post("""http://sxxx.....""")
.headers(headers_17)
.body(ELFileBody("CreateNonxxxx_request_0018.txt")).asJSON
.resources(http("request_18")
.get(uri1 + """/xxxxx"""))
)


In the request body, i.e. CreateNonxxxx_request_0018.txt

Notice how Gatling EL take those values from and parameter-ize it.

{
   
"Id": "",
   
"ActivityDate": "${ActivityDate}",
   
"MatterId": "${MatterId}",
   
"StaffRef": "${StaffRef}",
   
"TimeSpent": "${TimeSpent}",
   
"ActivityRef": "${ActivityRef}",
   
"ActivityDescription": "",
   
"ActivityComment": "${ActivityComment}",
   
"ActivityCommentMarkup": "",
   
"BillableEntityRef": "${BillableEntityRef}",
   
"BillableEntityDescription": "",
   
"RiskAreaDescription": "",
   
"RoleDescription": "",
   
"StatusDescription": "",
   
"ReviewComment": "",
   
"BillingPeriod": "",
   
"Summary": "${Summary}"
}

Murali Krishna

unread,
Sep 1, 2015, 5:23:21 AM9/1/15
to Gatling User Group
Thank You. Its working.
Reply all
Reply to author
Forward
0 new messages