How to add assertion for HTTP 204 content in REST

When I run a REST request, my answer is

HTTP / 1.1 204 No Content Date: Fri, Oct 01, 2010 5:18:11 PM GMT X-Response-ID: 10016

How to check it? Because it's a headline, I think. How to add a statement for this? When i decloare

+1
source share
2 answers

You can use the method of messageExchange.responseHeaders[field] to access the HTTP header fields, such as #status*, Content-Type, Accept, etc.

def http_status = messageExchange.responseHeaders["#status#"][0]
assert http_status.contains("204")
+2
source
import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )
def node = holder.getDomNode( "//data[1]/@contentType" )

assert node != null
assert((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["#status#"]).containsValue("HTTP/1.1 204 No Content")
0
source

All Articles