1

I am setting up an E2E test and chaining my request/responses. I am defining variables from each response and using them in the next call.

Its working up to a point, and then a problem surfaces when defining off the 2nd response.

If I def operationId, operationSubject, or operationStatus (e.g response.operationId), it works. If I store anything from the results (e.g response.results.0.personId) it throws this error Expected ; but found .0 response.results.0.personId

My response:

{ "operationId": "922459ecxxxxx", "operationSubject": "BATCH_ENROLLMENT", "operationStatus": "PROCESSED", "results": { "0": { "personId": "367a73b5xxxx", "status": "PRE_AUTH", "email": "mquinter+TEST.69387488@email.com", "loanNumber": null }, "1": { "personId": "56f060fd-e34xxxxxx", "status": "PRE_AUTH", "email": "mquintxxxx@email.com", "loanNumber": null } } }

mark quinteros
  • 129
  • 1
  • 7

2 Answers2

1

That's not how to access data in JSON. See this similar question: https://stackoverflow.com/a/71847841/143475

Maybe you meant to do this:

* def foo = response.results[0].personId
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • That is how I am defining it (ie. * def borrowerID = response.results.0.personId I also tried * def borrowerID = response.results.[0].personId ......either way get SyntaxError: Unnamed:1:17 Expected ident but found [ response.results.[0].personId * def borrowerID = response.results.[0].personId – mark quinteros Apr 13 '22 at 18:55
  • Full ERROR .......... [ERROR] Failures: [ERROR] ExamplesTest.testParallel:17 js failed: >>>> 01: response.results.[0].personId <<<< org.graalvm.polyglot.PolyglotException: SyntaxError: Unnamed:1:17 Expected ident but found [ response.results.[0].personId – mark quinteros Apr 13 '22 at 19:01
0

https://stackoverflow.com/users/143475/peter-thomas

I see the issue - It wasn't finding the response because I wasn't giving it enough time before the next call.

I put a sleep in there and its working as expected.

Thanks

mark quinteros
  • 129
  • 1
  • 7