API Testing · Middle · Question 53 of 75
Why check that error responses have the right Content-Type?
- 1Only successful responses are allowed to set
Content-Type - 2Clients parse errors by type; HTML errors break JSON clients
- 3Error responses don't have a body, so the type is ignored
Show the answer
Correct answer: Clients parse errors by type; HTML errors break JSON clients
Explanation
Proxies and frameworks often return HTML error pages. A JSON client then fails with a parse error instead of showing the message.