Ask a Question

How can I use a variable in Property transfer?

New Contributor

How can I use a variable in Property transfer?

I want to use a variable in the Property transfer screen. I use JSONPATH to extract an ID (see screenshot)

I use the variable: invoice_id = 1041


When I use the following JSONPATH expression I get the desired result in Property Transfer:



See Attachment: Desired Result


The problem is that '1041' is dynamic so I want to get value '1041' out of another property saved under the testcase:  



Therefore I use the following JSONPATH expression:



But now I get the error message: For input string: "${#TestCase#invoice_id}" See Attachment: Error


NOTE: When I use the same JSPATH expression in a assertion it works just fine.


Is there another way to get the same result? Or how is it possible to use a variable in Property Transfer.

New Contributor


Occasional Contributor



I encountered same issue, when using test case property for a JSONPath query. It just stops working (returns nothing). Any ideas for a workaround?


For path like this $[*][?(@.displayName==ABCD)]['id'] - property transfer correctly finds the value an puts it to Test Case property, but when I use another test case property instead of explicit string ABCD like this:




it stops working just returns null.



Super Contributor

A test case property can be used with JSONPath match assertions and XPath property transfers so JSONPath property transfer should work as well. It seems to be a defect because $ is a special character for JSONPath and property expansion.


Groovy script can be used as a workaround

(removed single quotes around id in JSONPath for this example)


def sourcename = 'source test step name'
def propname = 'test case property name'
def jsonpath = '$[*][?(@.displayName=="${#TestCase#AccountNumber}")].id'

transfervalue = context.expand("\${${sourcename}#Response#${jsonpath}}")
context.testCase.setPropertyValue(propname, transfervalue) transfervalue


Occasional Contributor

I thought that double quotes around ReadyAPI parameter name are serving this purpose. Anyways, @PaulMS thanks for help, appreciate that.

Showing results for 
Search instead for 
Did you mean: