API API success status code definition

different platforms and service providers use different interface status codes

but the common success status code is used by some people: 0, 1, 1, 100, 200, etc.

which is more in line with the specification and which is more general?

I usually use 1 for success. Welcome to discuss it.

Mar.28,2021

0 indicates success, and all exceptions greater than 0 are exceptions. Depending on the numerical value, the exception is different (custom), and it is simple and clear


.

there is no standard for this.
tell me about mine.

< H2 > StatusCode < / H2 >
  • all exceptions thrown by non-business use standard HTTP status codes.
  • 200 status codes are used for all businesses to throw exceptions.
< H2 > response body < / H2 >
  • unsuccessful response
{
    "errmsg":"",
    "errcode":1,// exceptioncode1errcode0
}
  • successful response
{
"user_id":1
}

[
{
"user_id":1
}
]

the data part is clean, and there are no flag fields such as succeed

Menu