cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Occasional Contributor

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 expansions? the Smartbear one from the Datasink component is not fit for purpose for a beginner.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

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

Hey @davecoleman 

 

just adding a little to expand on Rao's post

 

you will need the following testobject hierarchy in your test case

Capture.PNG

 

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

 

Capture2.PNG

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:

Capture3.PNG

 

Hope this helps out 

 

nice one,

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

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

Hi @davecoleman,

Im typing this on my phone, but i have the script you need (courtesy of @nmrao) to extract the status header value via a script assertion or groovy step.
You cant use the native functionality to extract http headers, hence the need to use groovy.
I'll post it when i get back in front of my laptop.

Nice one fella,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Occasional Contributor

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

thanks Rich. looking forward to it.

Highlighted
Community Hero

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

Highlighted
Community Hero

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

Hey @davecoleman 

 

just adding a little to expand on Rao's post

 

you will need the following testobject hierarchy in your test case

Capture.PNG

 

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

 

Capture2.PNG

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:

Capture3.PNG

 

Hope this helps out 

 

nice one,

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

Highlighted
Occasional Contributor

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

Many thanks guys. that worked. 

I will now use the example here: https://community.smartbear.com/t5/SoapUI-Pro/Resolved-Get-HTTP-Response-Code/td-p/44019# to compare this value to a record on the excel to complete the full assertion.

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Compete with community members in the TechCorner Challenge and get into the Leaderboard!

Rank Participant Points Earned
1 msiadak 12
2 nmrao 8
3 HimanshuTayal 3
Top Kudoed Authors