cancel
Showing results for 
Search instead for 
Did you mean: 

Script assertion to verify the response headers value

Occasional Contributor

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,

K

1 REPLY 1
Super Contributor

Re: Script assertion to verify the response headers value

@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

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal