1

I have an api example -

/get/userBundle

Request header - Accept = application/zip

Response assertion - status == 200.

If response status = 200, but response is NOT of type zip but json response or any other format, will the test fail without having any other assertion for response header or response body.

is it necessary to add assertion of response body to be zip or response header to be application/zip ? or response type is by default validated based on request header (Accept)

1 Answer 1

0

Response headers are not validated automatically. You can easily add them: https://github.com/karatelabs/karate#match-header

Here is an example:

* url 'https://httpbin.org/anything'
* method get
* match header Content-Type == 'application/json'

Personally I don't think these add much value.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks Peter for responding. What I mean is , if request header 'Accept' = 'application/zip', will this enforce API response to be of type zip? Will API call fail if response is anything other than type zip, like json response or plain text.
@sumit no. that's what I said, if you want to assert that the response has some specific header you have to do it yourself

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.