DEV Community

Do not misuse HTTP POST verb

Hey geeks,

I am here because I really wanted to shout this out loud to the community that according to the HTTP spec we should not use POST to create new resources.

Here is my understanding of what POST means after reading HTTP specification:

What the server will do with the data in the request body depends on what the server is set up to do with it. Different endpoints or resources, on the server, might handle the data in different ways based on their own specific logic or rules.

So why everywhere I look I see something like this:

HTTP verbs associated with CRUD

This is totally wrong. Or at least that's what I believe. Then what is right?

Use PUT http verb to create new resources

Important note: PUT is not only for creating new resources. It is can be used for replacing or creating new resources.

RFC doc for HTTP PUT: https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.4
And RFC doc for HTTP POST: https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.3

Some of you might disagree with my stand but the way I see it is that this is exactly what HTTP spec is communicating. BTW I also do not like the way that we use PUT HTTP verb to update partially since for that we should use PATCH HTTP verb.

Here is my LinkedIn post about it. Please share your thoughts and ideas on this.

Top comments (0)