Trying to *optionally* select a random ID - getting: jsonPath($.documents[*].id).findAll.transform.exists, found nothing

Hey,

So basically a business rule is that users can optionally have documents, but it’s acceptable to not have any documents in the JSON payload.

I’m trying to grab a random document and if we find one, then the second doIf() kicks in to request that document

Lines 8-12 here are doing this so far: https://gist.github.com/dragoonis/665343a9ea13eba127416aa8038d1f6f#file-test-scala-L8-L12

When the JSON payload has “documents: []” as an empty array (valid response)`
Line 8 here is causing the error: https://gist.github.com/dragoonis/665343a9ea13eba127416aa8038d1f6f#file-test-scala-L8

What’s the solution here to:

  1. make it optional to have documents
  2. choose a random document

Many thanks,
Paul

  1. https://gatling.io/docs/current/http/http_check/?highlight=optional
  2. https://gatling.io/docs/current/http/http_check/?highlight=findrandom

Hi Stephane,

I’m not yet on 3.0 but on the latest 2.x release.

Can you advise on how to approach the situation differently? Right now this is a blocker for me.

Many thanks,
Paul

Gatling 2 has reached end of life.

Hi Stephane,

I’m upgrading to 3.0.0 right now, so that you’ll help me.

I’ve got a syntax issue with 3.0.0 upgrade and I’ve created a post on this.

Many thanks,
Paul