Which HTTP status code I need to return to indicate "client software update required"? For example, the server changed the format of the data it used to serve, and older clients won't be able to work with this, so the client must upgrade to use the new data.
I don't want to use 404 or 410, because I want to indicate it's still a valid path. 415? Not sure.
The HTTP 426 Upgrade Required client error response code indicates that the server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol. The server sends an Upgrade header with this response to indicate the required protocol(s).
A 200-level response means that everything is working exactly as it should. 200: “Everything is OK.” This is the code that is delivered when a web page or resource acts exactly the way it's expected to. 201: “Created.” The server has fulfilled the browser's request, and as a result, has created a new resource.
The HTTP 200 OK success status response code indicates that the request has succeeded. A 200 response is cacheable by default. The meaning of a success depends on the HTTP request method: GET : The resource has been fetched and is transmitted in the message body.
UPDATE. An update can be implemented with an HTTP PUT or PATCH method. The difference lies in the amount of data the client has to send to the backend. 200 OK - This is the most appropriate code for most use-cases.
The majority of commenters are concerned that you're breaking old clients while using the same URI, which is a reasonable concern. That's why many APIs are versioned in the URIs themselves.
That said, why not just 400? The request came from an old client, so it's a bad request.
why not just include the minimum supported client version as meta data in the api response? Then the client can check and prompt the user to upgrade as needed. No need to use a particular status code, just check the meta data on any response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With