</>

Technology

Rest Assured

Difficulty

Beginner

Interview Question

What is REST and what are its key principles?

Answer

What is REST?

REST stands for Representational State Transfer. It is an architectural style for developing web services that:

  • Exploits the ubiquity of the HTTP protocol
  • Uses HTTP methods to define actions
  • Revolves around resources — every component is a resource that can be accessed through a shared interface

REST Architecture

  • REST Server provides access to resources
  • REST Client accesses and modifies those resources
  • Each resource is identified by URIs (Uniform Resource Identifiers) or global IDs
  • Resources can be represented in text, JSON, or XML

6 REST Constraints (Principles)

PrincipleDescription
StatelessEach request contains all info needed; server stores no session state
Client-ServerClient and server are independent and separated
CacheableResponses must be labeled cacheable or non-cacheable
Uniform InterfaceConsistent way to interact with resources
Layered SystemClient can't tell if connected directly to server or middleware
Code on Demand(Optional) Server can send executable code to client

Statelessness Explained

The client and server don't store information about each other's state. Since the server stores no information, it treats each request as a new request.

  • The client request must contain all information required for the server to process it
  • Client application is responsible for storing session state

Follow AutomateQA

Related Topics