Forum Discussion

divman's avatar
10 years ago

Resolved:Get HTTP Response Code

Hi, Sorry if this is repeated question, but i couldn't get the exact answer what i need. I send a REST service and get the response back. In JSON tab, i get the response what i need to get and a...
  • nmrao's avatar
    10 years ago
    Hope i got it.

    As i mentioned earlier, use script assertion.

    headers["#status#"] returns List. Looks you are asserting with string.
    So, you may use value coming from excel file for variable 'excelExpectedValue'

    def headers =  messageExchange.getResponseHeaders() headers["#status#"]
    assert ['HTTP/1.1 200 OK'] == headers["#status#"]
    // messageExchange.getResponseContent()
    headers["#status#"] instanceof List
    def actualStatus = headers["#status#"].get(0)
    def excelExpectedValue = '200 OK'
    def expectedStatus = 'HTTP/1.1 '+excelExpectedValue
    assert expectedStatus == actualStatus