You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are not logged in, e.g. using a valid access token
403
Forbidden
You are authenticated but do not have access to what you are trying to do
404
Not found
The resource you are requesting does not exist(including parent resource does not exist)
405
Method not allowed
The request type is not allowed, e.g. /users is a resource and POST /users is a valid action but PUT /users is not.
409
Conflict
If resource already exists.
422
Unprocessable entity
Validation failed. The request and the format is valid, however the request was unable to process. For instance when sent data does not pass validation tests.
500
Server error
5xx Server Error. An error occured on the server which was not the consumer's fault.
很多 restful guide book 都给出了 http 状态码规范,基本规则如下。
从收藏的文档中copy过来的,就不翻译了。
如果觉得以上状态码不能更具体的表述情况(某些业务中非常详细的返回信息),不建议另外找一个冷门的状态码来使用,一般更通用的做法是,在返回数据中包含额外的code 和 message,来表述具体情况。
设计 code 要有一定的规划,比如,对某个功能相关的错误设置相同前缀的 code,例如: 前缀 100
比较复杂的错误代码设计,可以参考 oracle dbms。但通常,我们自己的微服务达不到这样的复杂度,所以,适可而止。
The text was updated successfully, but these errors were encountered: