Forum Discussion

xx1234g's avatar
xx1234g
Occasional Contributor
13 years ago

How can I put multiple data in a single property?

Hi all,

I am currently working on a project required a complex nested properties.
For example:

DeviceRequest
Property Name Data Type
* device_name string
* device_info DeviceInfo

DeviceInfo
Property Name Data Type
* device_type string
* model_name string
* wan_ip string

When I call the DeviceRequest API, it required 2 properties (device_name & device_info).
Apparently, device_name is just a string, I can input any characters in it.
But "device_info" actually like an object contains multiple data (device_type, model_name, & wan_ip).

The only way I can think of is to type the data myself in the data textbox, but it would be very inefficient.
Ex:
 {   "device_type": "string",
"model_name": "string",
"wan_ip": "string" }




Are there any better ways to perform this kinda request?
I have tried the DataSource, but it only brings the values into the data textbox. It wouldn't include the property names that I showed above.
Please give me a suggestion.

Thank you

Andy

4 Replies

  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Tring you understand the issue. Would you please clarify the following?
    1. Are you using soapui Pro?
    2. What kind of API call you are making from soapui ? I mean test step type.
    3. Do you want to include test step properties with complex data? Isn't it possible to define primitive data type(by breaking into each) under custom properties of soapui?
  • xx1234g's avatar
    xx1234g
    Occasional Contributor
    Hi nmrao,

    Thanks for quick reply.

    1. I'm using SoapUI Pro.
    2. It's a RESTful PUT method
    3. Just like the image that I updated above. If this "Update_a_Device" API has to work, it must put the "device_info" data like that. Therefore, I just wondering if there're any better ways to do it. The structure is made by RDs, I'm just a QA that verify the APIs.

    Thank you~
  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Ok. I can see that device info is a string type. However, it is seemed to a map with key:value pairs.

    Don't about soapui Pro features, but sure there must be some way to use the data from datasource.

    This is how i can imagine the data source could be defined:
    DEVICE_NAME, DEVICE_TYPE, MODEL_NAME, WAN_IP
    dev1,dev_type1,model1,wanip1
    dev2,dev_type2,model2,wanip2

    soapui must allow to do something like this
    In the data mapping for device_info field - {'device_type':<col name from data source for DEVICE_NAME>, 'model_name':<col name from data source for >, 'wan_ip':<col name from data source for WAN_IP>}

    As you see in the attached image that device_info is string, internally application might have handled to use it as a map.
    and loop thru your datasource.

    Hope this helps.
  • xx1234g's avatar
    xx1234g
    Occasional Contributor
    Hi Rao,

    Thanks for your suggestion.
    I just found a post in forum about my request.
    http://www.soapui.org/forum/viewtopic.php?t=11065

    Under the "Better approach to JSON POST requests"
    1. How can I create a parameter with JSON style? I only found QUERY, TEMPLATE, HEADER, MATRIX, PLAIN, but NOT "JSON"...
    2. How can I create a JSON request in a PUT/POST request?
    3. If it works correctly, can this implement as for different levels in JSON? ex. { key:value {key:value} }

    Does any one know the detail steps for this approach? I just start using SoapUI recently.

    Thank you.

    BR.
    Andy