Forum Discussion

kailashlatad's avatar
Occasional Contributor
6 years ago

Script assertion to verify the response headers value

Hi ,

I am trying to  add asserions using script method for Response header, can you please suggest how to add it .


Currently addes as below but actually I need to value in header.


assert messageExchange.responseHeaders["Connection"] != null


Also I have to validate error response i.e. 401 , 400 & 500 from response , please suggest how can this achive.


Thank You,


1 Reply

  • kailashlatad ,


    You can use below code to get the header value and validate the same according to your need :


    def expectedHeader = ["Header"]
    def headers = messageExchange.response.responseHeaders
    def actualHeader = headers['Actual Header from response']
    assert expectedHeader == actualHeader