Introduction to HTTP methods

REST is build on top of HTTP protocol. It uses HTTP methods to communicate over the internet. Using different HTTP method REST API sends, update, delete and modifies data. We will see what are those methods and how they are mapped with REST.


What is HTTP method :

Whenever in our browser we type in a website URL, the browser sends an HTTP request to the server, where our requested website is deployed on. That HTTP request contains lot of data and a method. The method will define which type of operation you want to perform on the web server. For example if you want to see the website content, the method will be GET and if you want to send some data to the web server, the common method will be POST. Lets see each of them in detail.

  • GET :

    GET is a read-only operation. It is used to query the server for specific information. GET is an idempotent operation. Idempotent means that no matter how many times you apply the operation, the result is always the same. GET can be mapped with SELECT query.

  • POST :

    POST is non-idempotent operation. This method will create a resource and used to insert a database entry. Hence it can be directly mapped with INSERT query.

  • PUT :

    PUT is used to update the resource, but PUT completely changes the resource. If we want to partially change the record on a database PUT is not a suitable choice. Hence it cannot be mapped with the UPDATE query, we can map PUT with REPLACE query, where every entry in the record will be replaced.

  • PATCH :

    PATCH will be our choice if we want to perform UPDATE query. PATCH will only change the entries we specify in our request body. There can be a lot of confusion between PUT and PATCH all over the internet, and many people argue about the use of PUT and PATCH in REST API. You may see a developer using PUT method for partial update of a resource, but that is not as per the specification.  Make sure you are clear about the differences.

  • DELETE :

    DELETE is used to remove a resource. It can be mapped with the DELETE query. We need to pass the unique identification or ID of a resource or a database record to delete it.


    OPTIONS is used to get the information about the communication options of the resource you are interest in. This means with the help of OPTIONS method, you can see which HTTP operations are allowed on a particular resource.

  • HEAD :

    HEAD is exactly like GET except that instead of returning a response body, it returns only a response code and any headers associated with the request.

Please comment below what you think about this article, ask questions if you have any issues. We will be happy to help.

Series Navigation<< Installation of TestNGSend GET request using REST-Assured >>