Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
How to return information about errors from the rest api? Come up with your error codes? - bug-code.com Q&A

How to return information about errors from the rest api? Come up with your error codes?

0 like 0 dislike
17 views
How to return information about errors from the rest api? To come up with skai or error codes?
asked by | 17 views

1 Answer

0 like 0 dislike
Or use the standard:
200 -- OK (the request has been processed, to eat)
400 -- Bad Request (the request came nonsense) or 413 -- Request Payload Too Large (in the rare case if the request came too much rubbish)
403 -- Forbidden (no access to the resource is missing or invalid authorization token or something from this play)
404 -- Not Found or 410-Gone -- (there seems to be all clear, but there may come a ambiguity-whether there is no desired endpoint, then there is nothing to return. It is better to respond with 404 for missing (410-existing, but now missing forever) endpoint, and if not found the requested data, by the situation-or 200 with empty response, either 400 or 413)
405 -- Method Not Allowed (for example, if the PUT is sent GET, well, this is a classic implementation of the REST API; it may not be necessary if everything goes through POST, along with some "action":"make-me-coffee")
500 -- Internal Server Error or 503 Service Unavailable (here all is clear, it is customary to report that things are very bad)
501 -- Not Implemented (we have wait, they're closed, but tomorrow we will wait for 9:00 GMT. And maybe won't, but you hold)

https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
answered by
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers

0 comments

13.3k users

24,788 questions
46,220 answers
0 comments
13,321 users