Forum Discussion

davecoleman's avatar
davecoleman
Contributor
5 years ago
Solved

Rawresponse #status# - how to set Property Expansion value from this?

hi,  using ReadyAPI 3.0 how do I get the value of "#status#" from RawResponse? I want to output the value of "#status#" in a Datasink.   Does anyone have a good tutorial link on Property expansio...
  • richie's avatar
    richie
    5 years ago

    Hey davecoleman 

     

    just adding a little to expand on Rao's post

     

    you will need the following testobject hierarchy in your test case

     

    1.  add a script assertion on your REST request  - add in the following code to your script assertion

    //Takes one of the elements of the response Header
    def value = messageExchange.modelItem.testStep.testCase.testSteps["REST TestStep Name"].testRequest.response.responseHeaders["#status#"]
    //#status# is the name of the header you want to extract
    
    //Read this value into a parameter - writes the header value into the Properties test step
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    groovyUtils.setPropertyValue("Properties Step Name", "status",value[0])
    
    //status is the name of the Properties attribute that is created when you execute the REST TestStep
    // in my example my REST Step is entitled 'REST Request', my Properties step is entitled 'Properties' and the property created within the Properties step is entitled 'status'

    2.  Add a Properties step into the test

     

    Executing the REST Step will populate the Properties step with the above row

     

    3.  Add the DataSink step  into the test

    Add in a property (entitled status) in the DataSink.  In the property's value field, you can either right click and select 'Get Data' from the context menu and navigate to the status attribute within the Properties step OR you can just type the following value in (which is what is dynamically generated if you use the 'Get Data' function) '${Properties#status}' - see the following:

     

    Hope this helps out 

     

    nice one,

     

    rich