As others have already mentioned clearly, this is not about your app, rather about the protocol. If you are,
Quote:
updating database using POST HTTP Verb?
You are violating the HTTP protocol and the definitions for these verbs. Same is the case for other cases in your question. In a properly defined HTTP API, you utilize the verbs as actions on the resources, which are URLs. Read the following,
GET /people
POST /people/ request=body;stripped=intentionally
PUT /people/5
DELETE /people/10
Can you read what the above endpoints will do? What would happen if you send a request to
/people/10
with
DELETE
as verb? Can you enforce the policy of read-only on
GET
if, if, if your code does a deletion in the background?
It is also not just about you, it is about the users... It is about, how your users consume the API. Just like you, your users will also read the API and take a concept of what it does, and how they can perform an action.
There are several tools that let your audience consume your APIs, some of these tools are intelligent and understand what is the behavior and can let them decide and generate a test workflow. In these cases, a correct verb will help every party involved—you, the developer, tool itself. If you have a different thinking and approach for the development of APIs, you are allowed to, but that means
you need to force your users to consume the API in the similar fashion.
About Swagger Specification | Documentation | Swagger | Swagger[
^]
Postman | API Development Environment[
^]
For example, I can allow my users to create a new account using a
DELETE
request, and I can allow them to update their profiles using
GET
request. Does that sound good to you?
Afzaal Ahmad Zeeshan:
Right verb for the right task is what you need to implement in your API!
Forget the freedom that others are telling you about—it's a facade and it will hurt you ultimately. Sorry for the shameless attribution. :laugh:
Last but not least, HTTP methods need to follow a standard, like idempotency, read-only methods, safe methods, etc. Read here for more on that,
What is idempotency in HTTP methods? - Stack Overflow[
^].