I just started to get in touch with the web, and I don’t know a lot of common sense. Want to ask.
An API only has a post method. If someone accesses it through other methods, what kind of information needs to be returned.
besides. . A response must contain certain information. Can you give me a specific json example? .
Give you a kind-hearted person’s gitup link. There are many restful API documents in it, which will benefit you a lot.
restful api information gitup
If you only need the post method
you need to return
405 Method Not Allowed
ErrorAs for the response body, you can customize it
I usually
The restful protocol API has many request methods, and POST can be used as a general method to change data. There are two types of response. One is to directly return the information in the response header via HTTP. This is usually set in the header information when setting the return information. And if you want to use this as a business distinction, you can set custom fields according to the answer above. You can set them at will, and it will be OK if they comply with the team's development specifications.
Response header: code msg data. Generally speaking, this is all that is needed for projects. The api does not only have the post method
Are you saying that the answer does not meet the requirements of the question? It's noisy.
---------------Original answer------------------------
If you want "an api only has post method", then other requests should return
4xx
error code.The fixed information of the response needs to be agreed upon by the front and backends themselves. Usually at least three fields are required to represent the request status, data, and prompt information. In actual business, more can be added, for example: