In previous post, we have seen Introduction of HTTP methods.
In this post, we will see what is called safe methods in HTTP methods. This is an important interview question also.
All HTTP methods can be categorised in two categories: Safe methods & Unsafe methods.
We know that all HTTP methods deal with resource. Some read the state of resource or some create/update the state of resource.
If an HTTP method does not change/modify the resource information on the server side or perform read only operation, is called a SAFE HTTP Method. The reason it is called as a safe method as it does not alter resource information and prevents actual resource state. GET, HEAD and OPTIONS HTTP methods are safe methods. This methods perform read only operations. POST, PUT etc are unsafe methods.
Suppose, you develop an API which gives current interest rate on saving account. This interest rate should be updated only by authorized people. If any normal employee wants to see interest rate, employee needs to hit that API which gives him current interest rate and he should not able to edit it in any way. That API should be a GET http method.
Safe methods are methods that can be cached, pre-fetched without any influence to the resource.
But it is also possible that a GET method can change resource on server side as it depends on developers how they create it.
More about API Testing in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
Author: Amod Mahajan
My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning