我为一个带有纤薄框架的ios应用程序创建了一个Rest Api。 为了识别Post请求,我创建了自己的一组状态代码。 如下面的错误响应所示。
{"status":"Incorrect Pin","code":3}
{"status":"server error","code":4}
但我们的应用程序开发人员表示,这与国际标准不符。 他建议如下。
{"status":"Incorrect Pin","code":404}
{"status":"servererror","code":404}
我知道200,404,是基本的http状态代码,但这样的代码的国际标准是什么? 任何人都可以向我解释这个吗?
答案 0 :(得分:4)
我认为您正在寻找以下状态代码
100 => 'Continue',
101 => 'Switching Protocols',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => '(Unused)',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
426 => 'Upgrade required'
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported');
我取自REST API
编辑:已添加状态代码426 => Upgrade Required
,感谢@NisseEngström
Also you can look all the here https://en.wikipedia.org/wiki/List_of_HTTP_status_codes