HTTP Methods in RESTful Web Services

Umesh Dananjaya
3 min readMay 7, 2021

In this tutorial I’m going to teach about HTTP Method in RESTful Services. Restful services are used to do the crud operations. These crud operations are…

  • Create
  • Read/Retrieve
  • Update
  • Delete

When this crud operations are operating in RESTful services these services has guideline on HTTP methods. That guidelines are help to select correct HTTP method in particular operations. Those guidelines are make REST API easy to read. These are some methods to use RESTful API…

  1. GET
  2. POST
  3. PUT
  4. DELETE
  5. PATCH

Let’s take about one by one…..

GET Method

Get operation is used to retrieve data from the REST API. get method should be idempotent it means how many times we retrieve the data and the parameters are should not changed. Every time we get the same result.

HTTP request should return the 200(ok) Response it retrieve the data.

example:- 1. Retrieve all Users.

POST Method

POST operation should only create a new resource in REST API. Using this method we can update the but this operation not very frequently. This API call is now idempotent. HTTP Post method call is not cache control well. if we use this operation we have to include the cache control or expires header.

example:- 1. Register users.

PUT Method

PUT operation is used to update the exiting data. PUT method is idempotent it means user can same request several times.

PUT method should send correct response ad created the new resource. (201 created code)

DELETE Method

DELETE method remove the relevant data. This method is idempotent. if the data is deleted after any request system should return the 404 response. Delete can be asynchronous.

PATCH Method

PATCH method is used to partial update to the data. different between PUT and PATCH is PATCH is partially change the given data but PUT is used to replace the data.

Some HTTP Status codes

Repository URL for father details

https://github.com/shamoda/rc-paradise-api/tree/umesh

--

--