Groovy Script how to get data from response
Hello.
This is my first time using SOAPUI. I'm testing openweathermap api and I need to write groovy script which log 'Checking weather in ' + name
I wrote something like this but it's log Checking weather in null π
def json = new groovy.json.JsonSlurper().parseText(context.response)
context.testCase.setPropertyValue('name', json.coord.name.toString())
log.info "Checking weather in " + json.coord.name
Response:
{
"coord": {
"lon": -0.1257,
"lat": 51.5085
},
"weather": [ {
"id": 803,
"main": "Clouds",
"description": "broken clouds",
"icon": "04d"
}],
"base": "stations",
"main": {
"temp": 294.11,
"feels_like": 294.43,
"temp_min": 291.77,
"temp_max": 295.53,
"pressure": 1016,
"humidity": 83
},
"visibility": 10000,
"wind": {
"speed": 3.6,
"deg": 290
},
"clouds": {"all": 75},
"dt": 1661435430,
"sys": {
"type": 2,
"id": 2075535,
"country": "GB",
"sunrise": 1661403711,
"sunset": 1661454232
},
"timezone": 3600,
"id": 2643743,
"name": "London",
"cod": 200
}