【问题标题】:REST API standard status codesREST API 标准状态码
【发布时间】:2016-04-02 03:51:15
【问题描述】:

我为一个带有苗条框架的 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 状态代码,但这种代码的国际标准是什么? 谁能给我解释一下?

【问题讨论】:

    标签: php api


    【解决方案1】:

    我认为您正在寻找以下状态代码

                        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 感谢@Nisse Engström

       Also you can look all the here https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多