Wednesday 26 August 2015

Introduction to REST

REST stands for REpresentational State Transfer, it is a software architecture for building webservices. Usually REST is not for human consumption, it is for program consumption. The output of REST call is usually consumed by a program.

RESTful systems usually communicate over the Hypertext Transfer Protocol with the same HTTP verbs (GET, POST, PUT, DELETE, etc.) which web browsers use to retrieve web pages and to send data to remote servers.

For example, following REST API generates XML response. We can feed this xml response to some other application to process.


Resource
It is the fundamental concept in REST. It is similar to object in OOPS (Object oriented programming). A set of well defined methods are used to update/create /delete these resources.

Following HTTP methods are used widely to get information about a resource, update, create resource, delete resource.

Method
Description
GET
Retrieve some data
PUT
Update/create data
POST
Create new data
DELETE
Delete data
HEAD
Retrieve headers

Idempotent operations
An Idempotent operation is one that has no additional effect if it is called more than once with the same input parameters.
Method
Is Idempotent
Description
GET
YES
GET is a read-only operation. No matter how many times you call GET request, it has no impact on resource.
PUT
YES
PUT is generally used for update operation. No matter how many times you called update by using same parameters, it has same effect on the resource.
POST
NO
POST is used to create new resource. If you call POST 3 times, it creates 3 resources.
DELETE
YES
DELETE is used to delete resource. It has no impact if you call multiple times.
HEAD
YES
HEAD is read-only operation. It gives response code and headers information.




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment