3 ms·
Yeah, I hate APIs that return 200 with a JSON (or XML) body that says the response was anything but OK. Another bugbear is a server suddenly switching content
by voltagex_ 11y ago
Yeah, I hate APIs that return 200 with a JSON (or XML) body that says the response was anything but OK.
Another bugbear is a server suddenly switching content types for errors. If you're on IIS, make sure you're handling your own damn error pages so I don't suddenly have to account for an HTML 500 error page in my javascript code. Cisco's AXL API was a terrible offender for this one.
- bencollier49 11y agoAgree, the number of APIs I've dealt with which return 200 OK for everything and then drop errors into the body of the response is horrific. My favourite are the "200 OK" responses with a Java error trace in the body of the response.
- TheOtherHobbes 11y agoI've never used IIS, but isn't that confusing protocol codes with content codes? IMO HTTP status codes should return information about the HTTP transaction, and only about the HTTP transaction. If you run an API layer on top of that, that's a separate concern. So "Server busy" should not be in the same space as "That API request was bad." On my last project I returned 200 for successful transactions, 404 for missing pages, and 444/closed connection for 'Piss off and stop making inept attempts to hack this server, use it as a free proxy, or rack up your SEO stats." IPs trying any of the latter are blocked by Fail2Ban. 444 seems to have cut down on spam requests from botnets, and it's cheaper than serving a full 404 page.