Ask a Question

Property Transfer using JSONPath in 5.1.2

infitude
New Contributor

Property Transfer using JSONPath in 5.1.2

Hi,

 

Is there some guidance on using the JSONPath path language in Property Transfers with version 5.1.2?  It's great that we can now use this feature for testing our JSON based services but I'm a bit stuck trying to figure out the correct syntax.  Google has not been my friend in this case...

 

Thanks in advance fort any help...

4 REPLIES 4
nmrao
Community Hero

Re: Property Transfer using JSONPath in 5.1.2

Can you please post more details so that some can understand what you are trying to achieve. An example would be helpful.


Regards,
Rao.
infitude
New Contributor

Re: Property Transfer using JSONPath in 5.1.2

Hi, sure, I'm using SoapUI 5.1.2 and have a REST GET request (REQUEST1) that returns JSON which I have validated using jsonlint.com.  In a testsuite I create a new testcase with 2 test requests and a Property Transfer.  In the property transfer I set the source and target to the two testcase requests.  In the source, I set the property to 'Response' and the path language to 'JSONPath'.  In the target I set the property to Request and the path language to JSONPath.  Now, Im using http://goessner.net/articles/JsonPath/ for the syntax for JSONPath and have $.* in my source expression, which I think should be everthing in the response.  Now, when I run the property transfer I get "[Invalid JSON: { .... " in the transferred values.  Now, I'm assuming I have the syntax in the source expression wrong but I'm not sure.

Interestingly, and I'm not sure if this is important or not, the JSON shown in the JSON tab is 'not the same' as in the Raw tab (the "class" object is missing)...

 

Screen Shot 2015-03-19 at 2.52.57 pm.pngScreen Shot 2015-03-19 at 2.52.57 pm.png

 

infitude
New Contributor

Re: Property Transfer using JSONPath in 5.1.2

Hi, just to follow up on my previous post and state what I'm are trying to achieve;  I have a REST web service method that returns a JSON response.  I would like to extact a value from the body of the repsonse and pass it to another REST web service method that takes the value in the URL.  How would I do this in SoapUI 5.1.2?

 

Simplified Example  (not related to the screen shots in the previous post)

------------------------

First web service method;

 

GET /customers

 

{"customers": [

    {

     "firstName": "John",

     "lastName": "Smith",

     "customerId": "12345"

     }

]}

 

>> extract customerId from JSON response, then >>>>

 

second web service method with customerId 

 

GET /customer/12345

 

Dima
New Contributor

Re: Property Transfer using JSONPath in 5.1.2

to extract customerID try $.customers[0].customerId
this tool may help - http://ashphy.com/JSONPathOnlineEvaluator/

cancel
Showing results for 
Search instead for 
Did you mean: