Table of Contents

Getting started with TMS FNC REST Client

TTMSFNCRESTClient lets you call any REST API from one shared code base. This page takes you from an empty form to a working request that reads a live JSON response — no credentials required, using the public JSONPlaceholder test API.

Prerequisites

  • TMS FNC Core installed and its runtime package added to the project.
  • TMS FNC Cloud Pack installed.
  • For a real service: an account and API credentials (see Authentication).

Add the component

  1. Drop a TTMSFNCRESTClient onto a form, or create it in code.
  2. Configure the Request: set the host, path, query, and result type.
  3. Execute the request and read the response in a callback or response event.

Run your first request

The snippet below issues a GET against the JSONPlaceholder /posts endpoint and shows the raw JSON in a memo. Because Async is True by default, ExecuteRequestWithResultString returns immediately and the body arrives in OnRequestResponseStringRetrieved.

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;

That is the whole loop: configure Request, call an Execute... method, handle the response. Everything else — authentication, headers, streaming downloads, history — builds on this shape.

Next steps