Monday, July 20, 2020

Know the REST and Its Best


Introduction to REST


Most of you already know what REST is and how it works, here also I will try to give some basic understanding of the REST.

As you all know REST is a type mechanism which interacts with two or more systems to perform user provided actions or the business logic defined in it. REST runs on HTTP protocol. REST is simply known as “REpresentational State Transfer”.

REST is lightweight component as compared to SOAP services. As SOAP uses only XML, since XML is heavyweight component and REST uses JSON and JSON is or lightweight component and sometime REST uses XML also. Difference between SOAP and REST will give in details section.

Remember REST uses URI’s and URI stands for “Uniform Resource Identifier”. URI and URL are not same as URI is can be name, locator or anything and whereas URL (“Uniform Resource Locator”) is just locator.

REST Methods are also called REST HTTP Methods, below are the main methods used often.

  • GET - Read
  • POST - Create
  • PUT - Update
  • DELETE - Delete


GET Method: The functionality of this method is to performs get operations. This method just retrieves or fetches the data only from the provided destination which is defined in URI.


Here, “https://lgsofttest.blogspot.com” is the service name and “2014” is value for get method, here GET method reads the content which satisfies and meets the condition of GET method.
The http response code for GET method is 200 [OK] for success response and 404[Not Found] for bad request.

POST Method: This method is used to create new record/content in a database as per URI provided along with request body in the form of JSON or XML content. The http response code for successfully creation is 200[OK] or 201[Created] and 204[Not Created] for bad request.


PUT Method: This method is used to update existing record/content in a database as per URI provided along with request body. PUT method updates the existing record as per ID in the request and if finds update the record with response code as 200[OK] and 204[Not Created] for bad request.


DELETE Method: This method deletes the record or content from the database/resources for provided ID in URI. DELETE method deletes the existing record as per ID in the request and if finds update the record with response code as 200[OK] and 204[Not Created] for bad request or 404[Not Found].


GET
Read or retrieve record
POST
Add new record
PUT
Update existing record
DELETE
Remove record


SOAP Vs REST:

Now we will see the difference between SOAP and REST.

SOAP
REST
Simple Object Access Protocol 
REpresentational State Transfer
Uses XML and Schemas only
Uses XML, YMAL, JSON preferably
Performance wise slow
Performance wise if fast
Secured as use Object oriented and XML schemas
Not secured as stateless,
(with help of other conditions this can be made as secured)
Request and Response is always in XML
Can be any format, JSON, XML or RSS
Heavy weight component
Light weight component
Takes time to develop SOAP
Easy to develop


Tools
:
There are so many tools available in the market now days, it can pe paid or open sources and can find as per need like per license cost.
Most common and widely used tools are.

  • POSTMAN
  • SOAPUI or READYAPI
  • KATALON
  • Tricentis Tosca
  • JMETER
  • KARATE
And final one is “REST Assured”, this is not a tool its framework as we have TestNG and JUNIT just like that.

In next topic we will see how to work on “REST Assured” with using all REST methods and other topics.


                         That’s all Folks.



No comments:

Post a Comment