I’m using SoapUI to test REST webservices and I’m stuck on an issue.
I have a json object, called coverages, which consists of one or more other objects, it looks something like this (example with 2 coverages):
“coverages” : [
{
“CovNr” : 123,
“CovDesc” : “My coverage”
},
{
“CovNr” : 456,
“CovDesc” : “Another coverage”
}
]
The thing is, sometimes there is one coverage, and sometimes there are multiple. This means I need the coverages object to be variable, and have either one or more coverages as its body, depending on # of coverages.
Since the number of coverages isn’t always the same I can’t use properties for the CovNr and CovDesc attributes. Also I can’t just always add like three and leave two empty if only one is used (can’t have empty attributes).
I tried to set a coverages property using groovy script, which consisted of the entire body of the coverages object, but that didn’t work (I’m guessing the editor can’t parse an entire part of a request from a property).
Example of what I tried:
in groovy:
def coverages = “[ { “CovNr” : 123, “CovDesc” : “My coverage” }, { “CovNr” :456, “CovDesc” : “Another coverage” }]”
testRunner.testCase.setPropertyValue(“coverages”, coverages)
in request body:
…
“coverages” : “$(#TestCase#coverages)”,
…
This didn’t work.
Is there another way to add a variable number of coverages to my request body?