cancel
Showing results for 
Search instead for 
Did you mean: 

Property Expansions in JSONPath expression in Property Transfer step

SOLVED
New Contributor

Property Expansions in JSONPath expression in Property Transfer step

Hello SmartBear community

 

I'm new to using SoapUI and have got stuck on trying to use property expansions (for Test Case level parameters) in a Property Transfer step. I want to look up a value returned in a service response using the following JSONPath:

 

$.roles[?(@.service_name=='MyServiceName')].id

 

But I would like to parameterize the step to run for different environments, e.g.

 

$.roles[?(@.service_name=='${#TestCase#ServiceName}')].id

 

This doesn't seem to work - neither does the expression $.roles[?(@.service_name==${#TestCase#ServiceName})].id. I get the error "Array index [Ljava.lang.String;@1b02ce3 not found in path".

 

I have checked the property name is correct by using the same property expansion in my request (where it is expanded correctly), and I've checked my JSONPath expression works with a hard-coded value.

 

Any idea of where I am going wrong here?

 

Thanks
Lucy

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: Property Expansions in JSONPath expression in Property Transfer step

Hi Lucy,

 

Property expansions in JSONPath in Property Transfer are supported in Ready! API, but not in the open-source SoapUI. As a workaround you can use XPath instead. Change the source property from Response to ResponseAsXml and use this:

//*:roles/*[*:service_name='${#TestCase#ServiceName}']/*:id

 

In Ready! API 2.0, both your examples work if you add [0] at the end:

$.roles[?(@.service_name=='${#TestCase#ServiceName}')].id[0]
$.roles[?(@.service_name==${#TestCase#ServiceName})].id[0]

Helen Kosova
SmartBear Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.
4 REPLIES 4
Community Hero

Re: Property Expansions in JSONPath expression in Property Transfer step

Would you mind showing how the look like?


Regards,
Rao.
Moderator

Re: Property Expansions in JSONPath expression in Property Transfer step

Hi Lucy,

 

Property expansions in JSONPath in Property Transfer are supported in Ready! API, but not in the open-source SoapUI. As a workaround you can use XPath instead. Change the source property from Response to ResponseAsXml and use this:

//*:roles/*[*:service_name='${#TestCase#ServiceName}']/*:id

 

In Ready! API 2.0, both your examples work if you add [0] at the end:

$.roles[?(@.service_name=='${#TestCase#ServiceName}')].id[0]
$.roles[?(@.service_name==${#TestCase#ServiceName})].id[0]

Helen Kosova
SmartBear Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.
New Contributor

Re: Property Expansions in JSONPath expression in Property Transfer step

Thanks Helen! That worked perfectly.

Highlighted
New Contributor

Re: Property Expansions in JSONPath expression in Property Transfer step

Hi.

I tried to translate the line but in return I get "null".
Current line:
$[?(@.case_id=='${#Properties_case#case_ids_getClient_rez}')].id[0]
String after:
//*[*:case_id='${#Properties_case#case_ids_getClient_rez}']/*:id
What I doing wrong?

New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2
Top Kudoed Authors