Neste artigo de três minutos, quero abordar um assunto delicado.
Falaremos sobre o status do código HTTP 200 e os erros na resposta.
HTTP/1.1 200 OK
{
"error": {
code: 2019,
message: "Validation failed: field 'size' is invalid: the value is not a number"
}
}
, ?
? ? - .

1. HTTP 200 batch
. . 200. . . batch ?
, . API .
:
{
"sources": [
{"image": "http://myserver.com/image1.jpg"},
{"image": "http://myserver.com/image2.jpg"},
{"video": "http://myserver.com/video.jpg"}
]
}
, - (, ) . ? 2xx 4xx 5xx? , :
HTTP/1.1 200 OK
{
"results": [
{ "status": "ok", "id": 312 },
{ "status": "ok", "id": 313 },
{ "status": "fail", "error": "NO SPACE" }
]
}
( ) . 200. , .
2. HTTP 200
. . , - . , . - 200! .
- github bitbucket, . . «» . .
. :
— C, API. . . «error», .
— 4xx 5xx! ?!
— -. . . , . , , .
— …
HTTP 200 —
200 200. . . . ?! json !
, . ? ? ? ?
- . . . . .