- What is a SOA – Service Oriented Architecture
- Introduction to REST-API and REST-Assured
- REST Assured -Setting up environment using Maven
- Setting up environment without Maven
- Installation of TestNG
- Introduction to HTTP methods
- Send GET request using REST-Assured
- Send POST request using REST-Assured
- Send PUT request using REST-Assured
- Send DELETE request using REST-Assured
- REST-Assured Extracting values from the response.
- JSON Schema Validation In Rest Assured
- Send Query Parameter using REST-Assured
- Get Response Body in REST-Assured using JSONPath
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 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 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 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 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 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 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.