Forum Discussion

Titanium22's avatar
Occasional Contributor
8 years ago

How pull property value to the next json body request using proprty transfer?

Hey hey, lovely community! I need your lovely little support :D


I am testing API on one project. So, and faced with a question:

How pull property value which was taken in response to the next property in JSON body request using proprty transfer?


What I have

1. I have a request to a server from where I get a property in JSON body response which I want to move as value to the next 

body request. Here is screenshot:



Question number 2 is how to take this value from a header and pull into the header parameter "cookie" in next request?


Please, need your little support, ladies and gents!

7 Replies

  • nmrao's avatar
    Champion Level 3

    Not much familiar with Json Path along with Property Transfer. I would prefer to do it using Script Assertion for the first request test step.


    The following Script Assertion would fetch the required value and set the value test case level custom property and access the value using property expansion in the following test steps.


    assert context.response, "Response is empty of null"
    def parsedJson = new groovy.json.JsonSlurper().parseText(context.response) "Retrieved sms code : ${parsedJson.sms_code}"
    assert parsedJson.sms_code, "sms code is null or empty in the response"
    context.testCase.setPropertyValue('SMS_CODE', parsedJson.sms_code.toString())

    In the following request, use ${#TestCase#SMS_CODE} where you needed that value.


    And regarding your 2nd question, please refer the below script which is done some time for similar requirement.


      • nmrao's avatar
        Champion Level 3
        It was clearly mentioned that you need to use the provided script as "Script Assertion" for the request step where you get the response, no additional "groovy script" test step is needed.