Tag:javawebapi
Article From:https://segmentfault.com/q/1010000012148551
Question:

In the case of the question:

How to design the interface return code for the third party?

For example, the platform has many modules, different modules need to provide access to the third party company interface, return status and information using HTTP status code 200300 these are not reasonable, and what kind of return code can be friendly expression, different modules, different errors, such as parameter problems, system anomalies,Of course, there may be many kinds of correct returns.

Answer 0:

If your interface is restful, the wrong information is probably about these.

/**
 * httpState code* * /Private int status;/ * * * * ** exception coding, commonly used as HTTP status refinement and extension.* * /Private String code;/ * * * * ** readableAbnormal information* * /Private String message;/ * * * * ** information that only developers can understand* * /Private String developerMessage;

Correct return to general http statsu is 200, content per interface is different.

Answer 1:

RESTful API Design best practice
RESTful API practice

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *