Using previous request/response in tests not working

I have a test with 2 steps step one inserts data step 2 attempts to insert data with a duplicate ID that will cause a rejection from the api based on what I can see I should be able to do something like this {{$.1.response.body.syncId}} assuming that value is in the JSON response body (i tried request as well as both are json

however when I run that and look at the actual request I see {{$.1.response.body.syncId}} and there doesnt appear to be a way to debug what values are there. I have tried injecting in the whole body and still nothing.

if I create a global variable store the data in request 1 and then use the same global in the second test it works just fine.

What am I doing wrong in attempting to use this.

First, variables that obtain data from pre-steps will only acquire values during the execution of the entire test scenario. Have you also found incorrect values in the test report after running the entire test scenario?

Secondly, use ID + syntax to write a pre-step variable of course acceptable, you are a advanced user :smile:. But we also support visual clicking to insert a pre-step variables, as shown in the screenshot. This method ensures that the inserted variables do not have syntax errors.


if it only works running the whole scenario its hard to debug and see that its infact working I assumed as I was building my steps I could see the results of a previous step and use that within another step.
I see your point that when doing this as a full test suite run that makes sense but as I am building the test suite it means that I am unable to run it without running the whole suite

I am also wondering about local variables (documentation is unclear)
will the local variables be shared between steps? otherwise my only other choices are environment and global which can make those both messy

here is my example I am trying to solve for
Request 1 requires I send in a uuid
I would like to use faker and your data generator to generate that

Assert 1 on request 1 I want to assert the response contains the same uuid I actually sent in (right now the only way I can figure to do this is use a pre request script to set an env var)

Request 2 is completely different data but should have the same uuid as request 1
Assert that the response contains the same data we sent from request 1 (ie a text field was sent with request 1 if someone tries to “create” that same id we simply return the same data from the first request showing its already been created)
Assert that the response uuid matches the first one

Local variables are variable types that are kept in memory for use throughout a single run and released from memory after the run is completed. If running the entire test scenario, local variables are shared between steps. This is also the recommended variable usage in automated testing, as it avoids excessive maintenance of environment and global variables (unless you need to leave some data behind during a test scenario run for use elsewhere).

Currently, using pre-step variables does pose some difficulties during single-step debugging. We have received feedback like yours and are are looking for a better solution.

Yes, using the pre-step variables directly is very suitable for this case.