Script assertion to verify the response headers value
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.
Re: Script assertion to verify the response headers value
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,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
Thanks and Regards,