Should a 400 response have a body?
400 is always “Bad Request” and not “Bad Request – You Forgot To Specify The User ID”). Even if they won’t break, they won’t care about your special name for specific error code. The error does not belong in the body. It belongs in the Warning header.
Why does it say 400 Bad Request?
The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
Is the HTTP status code part of the REST API?
But today when someone asks me about HTTP Status codes, it is 99.9% refers to REST API web services development. I have lots of experience in both areas (Website development, REST API web services development) and it is sometimes hard to come to a conclusion about what and how use the errors in REST APIs.
How to look at REST API path vs request body parameters?
Look at REST API path parameters versus request bodies. Join the DZone community and get the full member experience. Whenever we create a REST API, we have to decide which parameter should be present where.
Can a bad request be a HTTP status code?
You can use “Bad Request” and include the id of the violated business rule plus some more details on the body of the response. Generally, I would avoid using HTTP status codes to represent specific business logic errors. This is because they already have a semantic meaning that is defined by the world-wide standard.
What does the rest specific status code 200 mean?
REST Specific Status Codes 200 (OK) It indicates that the REST API successfully carried out whatever action the client requested and that no more specific code in the 2xx series is appropriate. Unlike the 204 status code, a 200 response should include a response body.