Ask a Question

context values saved to a data sink

New Contributor

context values saved to a data sink

I would like to post the value of context parameters requestURI and httpresponseProperties to a data sink for a GET request. 

When I try the below groovy code I get null. any suggestions.

String therequestUri = new String(context.getProperty("requestUri").toString())




I would use the DataSink Test Step. After you add a property and name you can right click in the data sink value field toDatasink.PNG "get data" and pass properties very easily. 

Data Sink Test Step: 
Get Data Dialog: 

I have used data sink for many of my projects but cannot find a way to use get data for context, project or environment variables. 

Champion Level 2



You should be able to use a Groovy script to access context and environment variables.  Then, in your datasink, you should be able to call the Groovy script step to pull in the values of interest.


Do you have any specific examples?  If so, I can try and find a way.

Champion Level 2

In the meantime, here's some examples.  Note these are in a Groovy script step.."Current Environment - ${}")"Get the value for Test Case Property called 'TestCaseProp' - ${context.expand( '${#TestCase#TestCaseProp}' )}")"Get the value for Test Suite Property called 'TestSuiteProp' - ${context.expand( '${#TestSuite#TestSuiteProp}' )}")"Get the response status code for a named service call - ${testRunner.testCase.testSteps["REST Request"].testRequest.response.responseHeaders["#status#"];}");



Apologies for several messages.  I can't edit replies anymore."---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");"Current Environment - ${}")"");"Get the value for Test Case Property called 'TestCaseProp' - ${context.expand( '${#TestCase#TestCaseProp}' )}")"Get the value for Test Suite Property called 'TestSuiteProp' - ${context.expand( '${#TestSuite#TestSuiteProp}' )}")"");"Get the response status code for a named service call - ${testRunner.testCase.testSteps["REST Request"].testRequest.response.responseHeaders["#status#"];}");"");"Let's have a look at the response from a named test request...")["REST Request"].testRequest.response.getContentAsString() )"");"Root URL for a named request ${testRunner.testCase.testSteps["REST Request"].properties['Endpoint'].value}");"Get the path for a named service call - ${testRunner.testCase.testSteps["REST Request"].testRequest.getPath()}");"Get the full URL for a named service call.... ${testRunner.testCase.testSteps["REST Request"].properties['Endpoint'].value}${testRunner.testCase.testSteps["REST Request"].testRequest.getPath()}");"")"---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");


Here is the value I am trying to capture - requestUri

I cannot find any documentation regarding the testing and posting of these context values.

Any help would be greatly appreciated. See image below for my current test without the needed groovy




Showing results for 
Search instead for 
Did you mean: