How can i verify if body does not have any text i.e. is not null

I have to verify if the API body does not have any text.
I am able to verify that my API has required text but unable to verify if it returns blank data.

Does anybody has any idea on how to verify if body is not blank?

check the responseAsText size? since it is a string, is iterable … and have a size property too

Thanks Ibus
Can you please help me in writting command for this

response = WS.sendRequestAndVerify(findTestObject(‘or_brand’, [(‘rurl’) : vurl, (‘rbrand_id’) : vbrand_id, (‘rcat_id’) : vcat_id

        , ('rrange\_id') : vrange\_id, ('rcntry\_code') : rcntry\_code\]))

responsecode = response.getStatusCode()

println('Status Code is ’ + responsecode)

WS.verifyResponseStatusCode(response, 200)

responseText = response.getResponseText()

println('Response Text is: ’ + responseText)

WS.verifyElementPropertyValue(response, ‘[0].category_id’, 8279)

Vivek

I did a quick experiment with one of my test-cases (different API, doesn’t matter)
Option 1:

test = response.getResponseText()
println(test.length())

output (for a valid response):

11-21-2018 01:30:07 PM - [START]  - Start action : Statement - test = response.getResponseText()
11-21-2018 01:30:07 PM - [END]    - End action : Statement - test = response.getResponseText()
11-21-2018 01:30:07 PM - [START]  - Start action : Statement - println(test.length())
4063

so, for your case, something like:

assert response.getResponseText().length() > 0

should just work

Option 2:

with:

println(response.responseBodySize)

i get

11-21-2018 01:37:49 PM - [START]  - Start action : Statement - println(responseSize)
4063

so:

assert response.responseBodySize> 0

it is same as above, but less code.