I'm writing a RESTful API with some endpoints to which clients can PUT or POST chunked files (using flow.js), including a payload digest among the metadata. The server also calculates digest and will throw an error if the digests don't match, in which case the client should attempt to retry the same request with no change (at least until some retry limit is reached).
None of the standard codes seem to fit well by definition. What is the best code to use? Is there any that fits somewhat by convention?
Note: for the purposes of integration with this library, the response must not be 404, 415, 500, or 501 as they will cancel the larger operation rather than retry this portion.
I also cannot use 409 because that is being used to identify attempts to upload multiple copies of the same file, which I believe is a better use of 409 anyway.
The HTTP 201 Created success status response code indicates that the request has succeeded and has led to the creation of a resource.
HTTP error codes are not part of web pages; instead, they are responses from servers about how the request is handled. Not all HTTP status codes indicate errors. For example, some just communicate that a page has been moved, either permanently or temporarily.
2xx successful – the request was successfully received, understood, and accepted. 3xx redirection – further action needs to be taken in order to complete the request. 4xx client error – the request contains bad syntax or cannot be fulfilled. 5xx server error – the server failed to fulfil an apparently valid request.
Perhaps the most common status code returned is 200. It simply means that the request was received, understood, and is being processed, whereas the 201 status code indicates that a request was successful and a resource was created as a result.
I think more appropriate status code when same data from user going wrong, like corrupted data is:
400 Bad Request
For me corrupted data, means like syntax error caused by the transmission of data, semantically correct but syntactically erroneous.
422 Unprocessable Entity maybe apply too. https://www.rfc-editor.org/rfc/rfc4918#section-11.2
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