I got a json response and saved it for later use, but before I send the next http request, I need to change some attributes in the json payload. How can I do it?
Hello,
check this :
https://groups.google.com/forum/#!topic/gatling/msmrZWBiu74
Thanks William for the reply. I did check that post, and the solution Stéphane provided works perfectly if the json template is pre-defined. In my case, the template is returned from the server, and I need to change some attributes(id, creator, etc) and submit to server in the next request. What would be the recommended way of doing this?
In my case, the template is returned from the server, and I need to change some attributes(id, creator, etc) and submit to server in the next request. What would be the recommended way of doing this?
In that case, you have to save the template and change the attributes and submit it back to server.
- Save the template - use checks http://gatling.io/docs/2.1.7/http/http_check.html
- change the attributes - Use Scala functions or gatling transform http://gatling.io/docs/2.1.7/http/http_check.html?highlight=transform#transforming
- submit the request - whichever is easier http://gatling.io/docs/2.1.7/http/http_request.html?highlight=json#request-body
Many Thanks Abhinav. I was thinking the same as what you suggested. Where can I find some example for step 2? Especially on changing attributes for json. Either with Scala functions or gatling transform.
I haven’t tried it but have seen Stephane advising someone for JSON marshalling. https://nosqlnocry.wordpress.com/2015/04/16/working-with-json-in-scala-using-the-json4s-library-part-one/
Goodluck. Do share your code.