How to Modify a Response and Send it back as Request in the Next Step

book

Article ID: 15015

calendar_today

Updated On:

Products

CA Application Test Service Virtualization CA Continuous Application Insight (PathFinder)

Issue/Introduction

 

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?

Cause

 

N/A

Environment

 

All supported releases and platforms of DevTest.

Resolution

 

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".

 

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}}.

 

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}}.

 

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:

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

 

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

 

Additional Information

 

For more information regarding "Random Code Generator" data set refer to section Random Code Generator Data Set in the documentation of the version of DevTest you are running.

For more information regarding "Output Log Message" step refer to section Output Log Message in the documentation of the version of DevTest you are running.

Attachments

1558718379465000015015_sktwi1f5rjvs16uww.png get_app
1558718377262000015015_sktwi1f5rjvs16uwv.png get_app
1558718375585000015015_sktwi1f5rjvs16uwu.png get_app
1558718373771000015015_sktwi1f5rjvs16uwt.png get_app
1558718371929000015015_sktwi1f5rjvs16uws.png get_app
1558718369732000015015_sktwi1f5rjvs16uwr.png get_app