What are the differences between the Get and Post methods?
Get and Post methods are the most common method of HTTP. HTTP is an acronym for the Hypertext Transfer Protocol (HTTP). It enables communications between clients and servers as a request-response protocol.
There are several other methods than the Get and the Post. All of them have a specific purpose.
So what are the differences between the Get and Post methods?
- GET displays the submitted data as part of the URL.
- In the POST method, the request contains the encoded information
- GET can handle a maximum of 2048 characters,
- POST has no such restrictions.
- GET allows only ASCII data, POST does not have any such limitation, and we can use binary data also.
- Ideally, the GET method is for data retrieval.
- POST to insert and update.
Is there any difference between the put and patch methods?
Yes! There is. Check it for more details. The rest of this note uses the content of the link anyway!
- Put is similar to Post in that it can create resources, but it does so when there is a defined URL wherein Put replaces the entire resource if it exists or creates new if it does not exist.
- Unlike PUT Request, PATCH does partial updates e.g. Fields that need to be updated by the client, only that field is updated without modifying the other field.
|PUT is a method of modifying resources where the client sends data that updates the entire resource.
|PATCH is a method of modifying resources where the client sends partial data. It is not modifying the entire data.
|In a PUT request, the enclosed entity is a modified version of the resource in comparison to what is on the origin server. The client version will replace what is on the server.
|With PATCH, however, the enclosed entity contains a set of instructions describing how a resource currently residing on the origin server should be modified to produce a new version.
|HTTP PUT is said to be idempotent, So if you send retry a request multiple times, that should be equivalent to a single request modification
|HTTP PATCH is said to be non-idempotent. So if you retry the request N times, you will create N resources with N different URIs on the server.
|It has High Bandwidth
|It has Low Bandwidth because we send only the necessary resources in the payload.
Idempotence is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application.Wikipedia
When we receive a question, whether, in an interview or a technical debate, we realize the depth of our knowledge is limited. We can always go deeper and deeper. Furthermore, we can make notes that we can review from time to time to have up-to-date knowledge. So that’s why I have tried to detail the topic in this note.