People also ask, when should I send a bad request?
400 Bad Request: The request cannot be fulfilled due to bad syntax. In this case, your client sent you an XML payload that had an invalid zip code, which is a form of invalid syntax; therefore, sending a 400 Bad Request is an appropriate error code to return in this situation.
One may also ask, why am I getting a bad request? Check for errors in the URL. The most common reason for a 400 Bad Request error is because the URL was typed wrong or the link that was clicked on points to a malformed URL with a specific kind of mistake in it, like a syntax problem. This is most likely the problem if you get a 400 Bad Request error.
Similarly one may ask, why do I get bad request error 400?
A 400 Bad Request error means that the request the client made is incorrect or corrupt, and the server can't understand it. It indicates that the request the client submitted can't be processed by the server. In rare cases, it can be a problem with the server that's causing the error.
When should you throw internal server error?
If your API is trying to save a record to a database and this fails because there is an error with the database, for instance, it's not reachable, or a constraint fails, use a 5xx code (preferably 500 - Internal server error). Always add a response to what went wrong.