How to modify a response and send it back as request in the next step

Document ID : KB000015015
Last Modified Date : 14/02/2018
Show Technical Document Details

I need to store a JSON response in a property and change a certain value in the response property and pass it as a request to the next REST step.

How can I automate this process with DevTest?

All Supported DevTest Releases.

Here is an example if the response has always the same structure and we want to modify one specific field of this response.

1. Have the value you want to update in the response saved in a property or get the value from a data set.

In the example below, I am using the data set, "Random Code Generator", to generate a random value and I am saving this value to the property "newPrprty".



Test Case Random Data Set Example


2. Add an "Output Log Message" step after the REST step that receives the response you want to modify.


3. Copy the response from the REST step to the new "Output Log Message" step and modify the field you want to update with the property saved in the step #1 – {{newPrprty}}.


Test Case Output Log Message Step


4. In the REST step, that will send the updated response as the request, place the "Output Log Message" step response as the request body – {{lisa.Output Log Message.rsp}}.


Test Case New Rest Step


5. Save the modified Test Case.


When you run the test in the ITR you can see the new property being set in the first step:


ITR Results DataSet


The static response being updated in the "Output Log Message" step:


ITR Output Log Message Step


The response of the "Output Log Message" step being sent as the request body in the REST step:


ITR Updated Request


Additional Information:

For more information regarding "Random Code Generator" data set: Random Code Generator Data Set.

For more information regarding "Output Log Message" step: Output Log Message.