Table of Contents

TMS FNC REST Client

TTMSFNCRESTClient is a low-level HTTP REST client for integrating any web API that has no dedicated TMS cloud component. You describe a request once — host, path, query, headers, authorization, and body — execute it, and read the result as text, a stream, or a file, with the same code on VCL, FMX, and TMS WEB Core. Requests run asynchronously by default and every call is recorded for inspection.

Documentation

Start here Use when
Get started You want a working request running in a few steps.
Guides You want task-oriented chapters on requests, authentication, results, events, and REST Insight.
API reference You want class, property, method, and event details.
Release notes You want what changed in recent versions.

Minimal example

procedure TForm1.RunFirstRequest;
begin
  { Build the request from its parts. }
  TMSFNCRESTClient1.Request.Clear;
  TMSFNCRESTClient1.Request.Method := rmGET;
  TMSFNCRESTClient1.Request.Host := 'https://jsonplaceholder.typicode.com';
  TMSFNCRESTClient1.Request.Path := '/posts';
  TMSFNCRESTClient1.Request.Query := 'userId=1';
  TMSFNCRESTClient1.Request.ResultType := rrtString;

  { Async is True by default, so the call returns immediately and the
    response arrives in OnRequestResponseStringRetrieved. }
  TMSFNCRESTClient1.ExecuteRequestWithResultString;
end;

procedure TForm1.TMSFNCRESTClient1RequestResponseStringRetrieved(Sender: TObject;
  ARequest: TTMSFNCRESTClientExecutedRequest; AResultString: string);
begin
  Memo1.Lines.Text := AResultString;
end;

API map

The REST client is one component backed by a small set of request, response, and collection classes.

Main component

Class Role
TTMSFNCRESTClient The component you drop on a form: holds the request, executes it, raises response events, and keeps the execution history.

Request configuration

Class Role
TTMSFNCRESTClientRequest Host, path, port, query, method, body, and result settings for one call.
TTMSFNCRESTClientAuthorizationOptions Authorization scheme and credentials.
TTMSFNCRESTClientRequestQueryParameters Query-string parameter collection (AddParameter).
TTMSFNCRESTClientRequestHeaders HTTP header collection (AddHeader), shared by requests and responses.

Results and history

Class Role
TTMSFNCRESTClientResponse Status, body, size, timing, and response headers.
TTMSFNCRESTClientExecutedRequest One request execution and its captured response.
TTMSFNCRESTClientExecutedRequests The collection of executed requests kept by the client.

See also