HTTP methods (verbs)

REST endpoints become very popular in SaaS applications in recent times. We need to understand what http method used for what operation in general.

The important HTTP methods are as follows:

  1. GET method requests data from the resource and should not produce any side effect.
    E.g /companies/3/employees returns list of all employees from company 3.
  2. POST method requests the server to create a resource in the database, mostly when a web form is submitted.
    E.g /companies/3/employees creates a new Employee of company 3.
    POST is non-idempotent which means multiple requests will have different effects.
  3. PUT method requests the server to update resource or create the resource, if it doesn’t exist.
    E.g. /companies/3/employees/john will request the server to update, or create if doesn’t exist, the john resource in employees collection under company 3.
    PUT is idempotent which means multiple requests will have the same effects.
  4. DELETE method requests that the resources, or its instance, should be removed from the database.
    E.g /companies/3/employees/john/ will request the server to delete john resource from the employees collection under the company 3.

There are few other methods which we will discuss in another post.

Leave a Reply

Your email address will not be published. Required fields are marked *