Reputation: 129
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": "[email protected]", "loanNumber": null }, "1": { "personId": "56f060fd-e34xxxxxx", "status": "PRE_AUTH", "email": "[email protected]", "loanNumber": null } } }
Upvotes: 1
Views: 813
Reputation: 129
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
Upvotes: 0
Reputation: 58153
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
Upvotes: 1