Show: Delphi C++
Display Preferences

REST Overview

From RAD Studio
(Redirected from REST)
Jump to: navigation, search

Go Up to Developing EMS, Cloud, and REST Applications


REST stands for Representational State Transfer. It relies on a client-server architecture to design network applications that use the HTTP protocol to make calls between the machines.

Conforming to REST constraints is referred to as being RESTful. A RESTful web service is implemented using HTTP (hypertext transfer protocol) and the principles of REST.

REST Overview

The REST protocol assumes that the server is able to serve four types of requests: GET, POST, PUT, and DELETE. These operations represent Retrieve, Update, Insert, and Delete data operations. These operations are assimilated with the server methods through a mapping protocol. REST assumes that each server method can be invoked as one of the operations above through a dispatch mechanism that assumes a mapping between the URI (Uniform Resource Identifier) path, resource, and parameters.

The interface between servers and clients simplifies the architecture which enables each part to evolve independently.

Resource-Based

Resources are central to REST. A resource is a source of information that can be addressed using a URI. The server returns representations of the information to the client (HTML, XML, JSON).

You can use representations to modify or delete resources on the server.

URI Mapping

The server responds to URIs. Each resource on the server has its own address or URI.

The general HTTP request has the following format:

http://my.site.com/resource/items

HTTP Methods

HTTP methods are most commonly used to interact with the server resources:

Command type Description Example HTTP Response Code

GET

The HTTP GET method is used to read or retrieve a representation of a resource.
Get returns a representation in XML or JSON.

GET http://my.site.com/users/123

  • No errors:
    • OK: code 200.
  • Errors:
    • Bad Request: code 400
    • Not Found: code 404

PUT

The HTTP PUT method is most often used to update information.

PUT http://my.site.com/users/123

  • No errors:
    • OK: code 200.
    • No Content: code 204.
  • Errors:
    • Not Found: code 404

POST

The HTTP POST method is most often used to create a new resource.

POST http://my.site.com/devices
POST http://my.site.com/users/123/orders

  • No errors:
    • Created: code 201.
  • Errors:
    • Not Found: code 404

DELETE

The HTTP DELETE method is used to delete a resource identified by a URI.

DELETE http://my.site.com/users/123/orders

  • No errors:
    • OK: code 200.
    • No content: code 204.
  • Errors:
    • Not Found: code 404

See Also

Personal tools
In other languages
Previous Versions
Assistance