Ravan
Ravan

Reputation: 49

Few Misunderstandings of `STATE TRANSFER` in the acronym `REPRESENTATIONAL STATE TRANSFER`

So I have a few misunderstandings on the names STATE TRANSFER in REPRESENTATIONAL STATE TRANSFER.

Example: Consider a client requested the current share price of some X company by hitting /XCompanyPrice URI and at the current instance of time in the server the share price of the company x is 2 USD, and that is called the current state of the resource, and that resource state may change is what we can say? And that is what STATE means in the acronym REPRESENTATIONAL STATE TRANSFER?

OR

OR

Which is correct one in terms of REPRESENTATIONAL STATE TRANSFER.

So, the names state transfer in REPRESENTATIONAL STATE TRANSFER is saying the state of the application changes by data or Transferring representations of resource which is there in the server at the current time????

Please help.

Upvotes: 5

Views: 193

Answers (1)

Kevin Christopher Henry
Kevin Christopher Henry

Reputation: 49072

The only definitive source of information on the meaning of "REST" is Roy Fielding's dissertation introducing and defining that term.

The most succinct answer to your question is probably in section 5.2.1.2:

REST components perform actions on a resource by using a representation to capture the current or intended state of that resource and transferring that representation between components. A representation is a sequence of bytes, plus representation metadata to describe those bytes.... Depending on the message control data, a given representation may indicate the current state of the requested resource, the desired state for the requested resource, or the value of some other resource, such as a representation of the input data within a client's query form, or a representation of some error condition for a response.

In other words, a component (like a client or a server) operates on a resource by transferring a representation of its state to another component.

I don't entirely understand the various definitions and examples you mentioned, but I would say the last one is essentially correct. The second one seems incorrect since "state" here clearly refers to a specific resource and not a nebulous "application state".

Upvotes: 3

Related Questions