All Tutorials
5 HTTP Methods and their CRUD Operations
5 HTTP Methods and their CRUD Operations

5 HTTP Methods and their CRUD Operations

Understand the top 5 HTTP methods like GET, POST, etc and matching CRUD functions to perform operations.
Saurabh Dhingra
Founder, Uptut | Trainer & Consultant: DevOps, QA and IoT
QA
July 17, 2023
All trainings
5 HTTP Methods and their CRUD Operations

5 HTTP Methods and their CRUD Operations

Understand the top 5 HTTP methods like GET, POST, etc and matching CRUD functions to perform operations.

Whenever we enter a URL in the browser, there is an HTTP request which is sent to the web server, which then sends HTML content in response to the request. 

In simple words, HTTPS uses a URL (Uniform Resource Identifier) for the purpose of identification of resources and for making a connection. 

Features of HTTP

  • There is no connection in HTTP.
  • HTTP does not depend on the media which eases the transfer of all types of data.
  • Server and client cannot keep any records whatsoever of the previous requests. This makes HTTP stateless.

A standard format -RFC822 is used for the transfer of data.

Here are some essential components of this general message that we must know before we proceed.

  • Start line
  • Either Zero or more headers.
  • There is an empty line that indicates towards the header field’s end.
  • Message Body, which is optional

It is the HTTP header where metadata and information regarding the HTTP method is stored whereas the data to be sent to the server is stored in the body.

How to check HTTPS request

It is quite simple to check the HTTPS requests. 

For Chrome browser, Select F12(Windows) and Command + Option + I for Mac OS. This path leads to Developer tools. Click on the tab labelled ‘Network’ to see the HTTP requests and received responses. We can also check the headers here. 

These HTTP requests are sent by using many HTTP methods.Let us understand the HTTP methods in brief.

HTTP Methods

- GET

It is used generally to read (sometimes retrieve) a representation of a resource. If this method is successful without an error, it returns a representation in JSON along with a response status code 200. 

In case of an error, usually, it returns 404 (NOT FOUND) or 400 (BAD Request).

- POST

The most common use of this method is for creation of new resources, mainly subordinate resources which are subordinate for other parent resources. When a new resource is created, POST is responsible for mapping the new resource to the parent resource and also for assigning a new URI. Once this is completed without an error, it returns HTTP response code 201.

- PATCH

This method is mainly used for modification of resources. This request must only have the changes to be made to the resource and does not need the entire resource. The body needs to have clear instructions for making modifications to a resource that resides on the server. 

PATCH is not a safe resource and there may be instances of collision with different PATCH requests which can corrupt the resources as they could be in different formats.

- DELETE

This request is used for deleting a resource which is identified by an ID or filters. When this request is completed successfully, it returns response status code 204.

When a resource is deleted and yet, a DELETE request is sent multiple times, it may return the response code 404 (NOT FOUND) because the resource was already deleted and could not be found.

- PUT

This method is used for replacing or updating data which is either present on the server with the data passed on in the message body.

Now that we know the most commonly used HTTP methods, we must also include CRUD Operations in the discussion.

What are CRUD Operations?

CRUD is an abbreviation that stands for Create, Retrieve, Update, and Delete

The term CRUD Operations is used for describing the process of implementation of basic operations of a database. It is important to understand the process of implementing CRUD functions, for instance, creating a new table or changing an existing table in the database.

Importance of CRUD Operations

  • CRUD Operations are also referred to as the building blocks for any database. The functionality of the application totally depends on the data stored in the records. It is almost impossible to imagine any database to function without the CRUD Operations. 
  • One or some of the CRUD operations can be executed on multiple tables in a database and in some situations, it may be required to execute different operations on the same table.

Here is a brief explanation of each of the CRUD operations:

1) Create Operation

  • It is used to add new rows to the database.

2) Retrieve Operation

  • It is used to get one particular row from the database.

3) Update Operation

  •  It is used for making changes to the value of one particular column in a row that already exists.

4) Delete Operation

  • This operation is used for deleting records from the table.

HTTP methods and matching CRUD Operations

Did you notice that some of these CRUD operations actually do match up to the HTTP methods? Some of the HTTP methods which perform the same function as HTTP method are –

HTTP methods and matching CRUD Operations

Difference between PUT and PATCH request

Based on the above mapping, interestingly many people think that PUT and PATCH requests have the same function. 

However, this is not true. While the PUT and PATCH requests perform the same task of updating a resource at a given location, the methodology for both these requests is different. 

PUT method updates the complete resource as per the data sent by the client, whereas, PATCH method executes partial updates to a resource.

The table below mentions a few more points of difference between PUT and PATCH requests:

Conclusion

The most common HTTP methods include POST, GET, PUT, PATCH and DELETE have been discussed above. These are the HTTP methods which also relate to the CRUD Operations namely (Create, Read, Update and Delete). Many of the other HTTP methods are not used commonly.

Great job on getting one step ahead in learning about APIs. When it comes to execution, let us help your team with an expert-led, personalised approach to implement QA practices. 

We now move to the next part of our API Testing journey to understand types of web services. Broadly, the web services are of two types-

Let’s understand these a little better.

Excited to upskill?

Learn LIVE from experts with your team. Request a free expert consultation and plan the training roadmap with Uptut.
talk to an expert
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.