REST is one of the main models that has been described by Roy Fielding, one of the principal creators of the HTTP protocol, in his Ph.D. thesis and adopted as the model to be used in the evolution of the HTTP protocol architecture.
The Embarcadero REST Library is accessible for all platforms, supported by Delphi. RESTRequest4Delphi is a wrapper around the built in components.
The framework focuses on JSON as the representation format. The XML format is not supported.
The Embarcadero REST Library consists of three main components—the request, the client, and the response. All are part of a single workflow when submitting, processing, and returning the request with JSON.
Regarding the certain RESTRequest4Delphi library, there are some steps that you might want to check, before using it. Note the following sample code is from the author of the library.
Table of Contents
Quickstart
You need to use RESTRequest4D.Request
1 |
uses RESTRequest4D.Request; |
- GET
1 2 3 4 5 |
begin TRequest.New.BaseURL('http://localhost:8888/users') .Accept('application/json') .Get; end; |
- GET AS DATASET
1 2 3 4 5 6 |
begin TRequest.New.BaseURL('http://localhost:8888/users') .Accept('application/json') .DataSetAdapter(FDMemTable) .Get; end; |
- POST
1 2 3 4 5 6 |
begin TRequest.New.BaseURL('http://localhost:8888/users') .Accept('application/json') .Post; end; |
- PUT
1 2 3 4 5 6 |
begin TRequest.New.BaseURL('http://localhost:8888/users/1') .Accept('application/json') .Put; end; |
- DELETE
1 2 3 4 5 |
begin TRequest.New.BaseURL('http://localhost:8888/users/1') .Accept('application/json') .Delete; end; |
🔒 Authentication
You can set credentials using the BasicAuthentication
or Token
method before making the first request:
1 2 3 4 |
begin Request.BasicAuthentication('username', 'password'); Request.Token('bearer token'); end; |
You can set it once and it will be used for every request.
📝 Samples
Two projects were developed within the examples folder:
- client: Windows VCL application consuming a REST API developed in Node.js
To run the project, you need to install its dependencies (DataSet-Serialize). To install using Boss, open a terminal and type:
1 |
boss install |
⚠️ License
RESTRequest4Delphi
is free and open-source software licensed under the MIT License.
If you want to download this library, please follow the link below:
https://github.com/viniciussanchez/RESTRequest4Delphi
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition