Cherry
Cherry

Reputation: 33544

How select json value in soapui property transfer from HTTP request?

Here is a raw response:

HTTP/1.1 200 OK
Date: Tue, 21 Oct 2014 08:46:31 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Server: Jetty(9.2.2.v20140723)

{"id":"myId"}

I tried to set Property (source is response from another test step, property can be Request, Response etc.) Response and ResponseAsXML and for both I can not extract value. And try xPath selection but it does not work. Is it possible to extract id from HTTP response with json?

UPDATED

If I select ResponseAsXml I get the following string:

[<Response xmlns="http://localhost/path">
   <id>882fe993-d150-b67c-4b0f-014931e2dd21</id>
</Response>]

I have tried xPath:

declare namespace sam="http://localhost/path";
//sam:response

Also I wrote //sam:Response or //response result is [null] string.

Upvotes: 3

Views: 18717

Answers (2)

mari
mari

Reputation: 107

Within REST Request, we get a response which is a JSON Object:

Rest Request with a JSON Object response

and when we want to transfer this response with Property Tranfer: we can leave Source text field empty and we will tranfer the whole JSON object, if we want to tranfer a data of this object which is in this case name we set the source text field $.name and we are now able to retrieve a specific data of the JSON object.

Retrieve JSON Data within Property Transfer

Upvotes: 6

Tomas
Tomas

Reputation: 11

It worked for me as in the comment for this answer: SoapUI - How to use Property Transfer with POST request

You can simply use:

//*:id

Upvotes: 1

Related Questions