Forum Discussion

chandanakki's avatar
chandanakki
Occasional Contributor
12 years ago

How to use Property Transfer for a Rest API

Can someone please help me. I am using Soap UI 4.6 Free version & also new to Soap UI

This is a REST API (JSON POST Request)

How can i extract only the device id' from my 1st response. In this i also need to include orgnumber & user.

The 1st JSON REST POST Request is in this format {"orgnumber":100,"user":229}

Its Response is in the below format .

[
{
"deviceID": "10000",
"osVersion": "12.2(11)T6",
"productFamily": "C2600",
"pid": "
},
{
"deviceID": "13999",
"osVersion": "12.1(22)EA6",
"productFamily": "C2950",
"pid": ""
},

]

Now 2nd JSON REST POST Request is in the below format which is nothing but i will update the first response Device Id's.

{
"devices"
{
"deviceID":"10000"
},
{
"deviceID":"13999"
},

],
"orgnumber":100,
"user":229
}

Please do the needful.

Thanks In Advance,

Best Regards,
Chandan

3 Replies

  • SiKing's avatar
    SiKing
    Community Expert
    In Property Transfer use the ResponseAsXml and then you can use XPath.
    Alternatively you will need to use JsonSlurper(), see this post viewtopic.php?t=21569
  • chandanakki's avatar
    chandanakki
    Occasional Contributor
    Hi Siking,

    I was able to extract the device Id from my 1st response & was able to pass it to the next Request using Properties & Property Transfer steps.

    But i was able to extract only a single device id using Xpath. I need to extract multiple device id's from my 1st response. Can you please help me on this on how to write the xpath for this

    Below is my 1st response e.g i want to grab the first three device ID's

    [
    {
    "deviceID": "10000",
    "osVersion": "12.2(11)T6",
    "productFamily": "C2600",
    "pid": "
    },
    {
    "deviceID": "13999",
    "osVersion": "12.1(22)EA6",
    "productFamily": "C2950",
    "pid": ""
    },
    "deviceID": "20000",
    "osVersion": "12.2(11)T6",
    "productFamily": "C2600",
    "pid": "
    },
    {
    "deviceID": "23999",
    "osVersion": "12.1(22)EA6",
    "productFamily": "C2950",
    "pid": ""
    },

    ]
  • SiKing's avatar
    SiKing
    Community Expert
    You posted JSON and are asking for XPath? You must understand that SoapUI creates an internal representation of this data that looks like XML. So I would have to guess what happens in your case.

    The XPaths might be something like:
    //*:e[1]/*:deviceID
    //*:e[2]/*:deviceID
    //*:e[3]/*:deviceID