DevNet Associate (DEVASC) v1.0Understanding and Using APIsMedium

A junior developer is confused about the differences between REST, SOAP, and GraphQL. The lead developer explains that REST APIs are characterized by being stateless, using standard HTTP methods, and representing resources with URLs. Which of the following best describes the 'stateless' characteristic of REST APIs?

  1. AClients are required to send an authorization token only on their first request to the API.
  2. BThe API server stores client-specific session data to optimize subsequent requests.
  3. CThe API server maintains a persistent connection with the client throughout the session.
  4. DEach request from the client to the server must contain all the information needed to understand the request, without the server relying on previous requests.
Show answer & explanation

Correct answer: D. Each request from the client to the server must contain all the information needed to understand the request, without the server relying on previous requests.

Statelessness in REST means that the server does not store any client-specific context between requests. Every request from the client must be self-contained and include all necessary information for the server to process it independently of any previous interactions.

Why the other options are wrong

  • A. Authorization tokens typically need to be sent with every request in a stateless API, not just the first, because the server doesn't remember previous authentications.
  • B. Storing client-specific session data (server-side state) is the opposite of statelessness.
  • C. Maintaining a persistent connection implies statefulness, which contradicts REST's stateless principle.

REST Statelessness

A core principle of REST where each request from client to server contains all the information necessary to understand the request, and the server does not store any client context between requests.

  • Each request is independent and self-contained.
  • Server does not rely on previous requests or sessions.
  • Simplifies server design and improves scalability.

Memory trick: REST: Client-Server, Stateless, Cacheable, Layered, Uniform Interface, Code-on-Demand (optional).

More Understanding and Using APIs questions