Having trouble with POST call with list in body


I’m using Gatling 3.2.1 and having problems calling a method with a list as parameter.

The list is saved as “IdsLettresRecrutement” from a previous call and then used in the body of the next call.

The method is called correctly but the list is parameters is always null.

val obtenirLettreRecrutementAProduire = http("Obtention des lettres de recrutement à produire")
  .get(urlServeurRequete + contexte + "/RequeteLettreRecrutement/ObtenirAProduire?sort=NAM-asc&page=1&pageSize=1000&group=Lettres-asc&aggregate=Lettres-count&filter=")

val scn = 
  .exec { session =>
  // Production des lettres
  exec(http("Production des lettres de recrutement")
   .post(contexte + "/LettresRecrutement/Produire")
   .body(StringBody("""{ "guidsDocumentsSelectionnes":"${idsLettresRecrutement}" }""")).asJson

Hi Francois,

If you turn on debug logging in Gatling, you can see what your EL expands to.

To properly put a list in a JSON, try using jsonStringify in the EL.

“”"{ “guidsDocumentsSelectionnes”: ${idsLettresRecrutement.jsonStringify()} }"""

Notice that there is no quotes surrounding the JSON array.

These two pages of the documentation are helpful: