Saving POST response using ELs

Hey guys, I started using Gatling today and I must say it’s quite an impressive tool. Bravo! to the developers.

I have one question that I couldn’t find the answer on the internet. How can I save the response from a POST request (it returns a JSON) by using ELs?

.exec(http(“GET LIST”)
.post("/en/get-list")
.headers(headers_10)

I want to save the response in EL’s for using them in another request in the .fileBody() method (I’m using SSP templates, or at least I’m trying).

Thank you very much!
Keep on the great work!

Hi,

Thanks for your kind words.

If you want to extract values from your JSON, you can use JsonPath or regex checks :
https://github.com/excilys/gatling/wiki/Checks#wiki-json

Be aware that you won’t be able to use Gatling EL inside SSP, which is a Scalate templating format. You have to explicitly pass the desired values from the Session to the the SSP template as shown in the documentation.

In Gatling 2, it will be possible to have Gatling EL templates. This feature is already present in the master, but it’s not documented.

Cheers,

Stéphane

Can you give me an example please? I can’t find my way in doings this.

Let’s say I have this response:
{“error”:false,“rid”:8158}

I do it like this:
.check(jsonPath("//rid").saveAs(“rid”))

But it still returns c.e.e.g.c.s.ELParser$ - Couldn’t resolve EL ${rid}

You’re doing it right.
See https://github.com/excilys/gatling/blob/1.4.X/gatling-core/src/test/scala/com/excilys/ebi/gatling/core/check/extractor/jsonpath/JsonPathExtractorSpec.scala

I think that your response body is not what you expect. Try logging the requests and response: https://github.com/excilys/gatling/wiki/Configuration#wiki-config-files.

Sorry! My bad! A freakin’ typo. Everything works ok right now! Thank you again for your invaluable help.

Cool!
Have fun!