What is the most appropriate HTTP status code to return if a required header is missing?

400 Bad Request It’s a user error in the request. Unlike with a 403, the client should be allowed to repeat their request, but only after modification: 10.4.1 400 Bad Request The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. Edit As … Read more

Getting 400 bad request error in Jquery Ajax POST

Finally, I got the mistake and the reason was I need to stringify the JSON data I was sending. I have to set the content type and datatype in XHR object. So the correct version is here: $.ajax({ type: ‘POST’, url: “http://localhost:8080/project/server/rest/subjects”, data: JSON.stringify({ “subject:title”:”Test Name”, “subject:description”:”Creating test subject to check POST method API”, “sub:tags”: … Read more

HTTP 400 (bad request) for logical error, not malformed request syntax

Status 422 (RFC 4918, Section 11.2) comes to mind: The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was … Read more

What are the possible reasons to get APNs responses BadDeviceToken or Unregistered?

As you’ve quoted from Table 8-6 in the APNS documentation, there are two possible causes for the error: That the device token is invalid That the device token does not match the environment If it is the first case, make sure that the iOS app registers the device for remote notifications every single time that … Read more

Returning http 200 OK with error within response body

No, it’s very incorrect to send 200 with a error body HTTP is an application protocol. 200 implies that the response contains a payload that represents the status of the requested resource. An error message usually is not a representation of that resource. If something goes wrong while processing GET, the right status code is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)