1. Home
  2. /
  3. Docs
  4. /
  5. Articles Report Writer
  6. /
  7. Database Components
  8. /
  9. RESTTable

RESTTable

REST Table

The REST Table component fetches data from a REST API endpoint and makes it available to the report just like any other dataset. It sends an HTTP GET request to a URL you specify, parses the JSON response, and loads the results into an in-memory table. Report bands bind to it and display the data exactly as they would with an FD Query or FD Table.

REST Table does not require an FD Database component — it manages its own HTTP connection independently.

When to Use REST Table

Use REST Table when your data comes from a web API rather than a database. Common examples include:

  • Fetching live pricing or inventory from an external system
  • Pulling customer or order data from a cloud platform
  • Reading results from an internal REST API that aggregates data from multiple sources
  • Any situation where the data source is a URL rather than a database connection

If your data is in a database, use FD Query or FD Table instead.

Adding a REST Table to Your Report

  1. Find the REST Table component in the report designer component panel
  2. Drag it onto the designer surface
  3. Click the URL property — a URL editor dialog opens
  4. Enter the full URL of the API endpoint, for example https://api.example.com/v1/invoices
  5. Set the AuthType property if the API requires authentication
  6. Set RefreshData to True to test the connection and load the fields
  7. Bind report bands to the REST Table component

Properties

URL
The full URL of the REST API endpoint to fetch data from. Click the property to open the URL editor dialog where you can enter long URLs comfortably. The URL can be a plain address or it can include query string parameters, for example https://api.example.com/invoices?status=unpaid.

RefreshData
Set this to True in the Object Inspector to immediately fetch the URL and load the data at design time. This is the design-time test button — it lets you verify the connection works and loads the fields so you can bind them to bands without running the full report. It always resets to False — it is a trigger, not a toggle.

AuthType
The authentication method the API requires. Options are:

  • atNone — no authentication (default). Use for public APIs.
  • atBasic — HTTP Basic authentication. Set AuthUserName and AuthPassword.
  • atBearer — Bearer token authentication. Set BearerToken.
  • atOAuth2 — OAuth2 client credentials flow. Set ClientID, ClientSecret, and TokenURL.

AuthUserName
The username for Basic authentication. Only used when AuthType is atBasic.

AuthPassword
The password for Basic authentication. Only used when AuthType is atBasic.

BearerToken
The bearer token for Bearer authentication. Only used when AuthType is atBearer. Enter the token value directly — Articles adds the Bearer prefix automatically.

ClientID
The client ID for OAuth2 authentication. Only used when AuthType is atOAuth2.

ClientSecret
The client secret for OAuth2 authentication. Only used when AuthType is atOAuth2.

TokenURL
The URL of the OAuth2 token endpoint. Only used when AuthType is atOAuth2. Articles fetches a token from this URL using client credentials and uses it to authenticate the data request. If the token expires during the report run Articles automatically fetches a fresh one and retries.

Filter
A filter expression applied to the in-memory data after it is loaded. This filters rows in memory without making another API call. Use standard dataset filter syntax.

FilterActive
Set to True to activate the Filter expression. Set to False to show all rows.

MasterSource
The master dataset for master-detail linking. When set, the REST Table filters its in-memory data automatically each time the master moves to a new row. See Master Detail with REST Table below.

MasterFields
The field names in the master dataset to link on. Separate multiple fields with a comma.

DetailFields
The field names in the REST Table to match against MasterFields. Separate multiple fields with a comma. The order must match MasterFields exactly.

LastError
Read-only. Contains the error message from the last failed fetch. Click the property in the Object Inspector to open a dialog showing the full error text. Empty if the last fetch succeeded.

Authentication

No Authentication (atNone)
Leave AuthType at atNone for public APIs that require no credentials. Articles sends the GET request with no authentication headers.

Basic Authentication (atBasic)
Set AuthType to atBasic and enter AuthUserName and AuthPassword. Articles sends the credentials using HTTP Basic authentication on every request.

Bearer Token (atBearer)
Set AuthType to atBearer and enter the token in BearerToken. Articles adds Authorization: Bearer your-token to every request. Use this for APIs that issue static API keys or long-lived tokens.

OAuth2 (atOAuth2)
Set AuthType to atOAuth2 and enter ClientID, ClientSecret, and TokenURL. Articles fetches an access token from TokenURL using the client credentials grant, then uses it to authenticate the data request. If the API returns a 401 Unauthorized response, Articles automatically fetches a fresh token and retries the request once. Use this for APIs that issue short-lived tokens.

Testing the Connection at Design Time

After entering the URL and authentication settings, set RefreshData to True in the Object Inspector. Articles immediately sends the request and reports the result:

  • If successful — a message shows how many records and fields were loaded. The fields are now available to bind to report bands.
  • If failed — a message shows the error. Check the LastError property for the full error details including the HTTP status code and URL.

You can set RefreshData to True as many times as you like during design. Each time it re-fetches the URL and reloads the fields.

How JSON Is Parsed

Articles expects the API to return a JSON array of objects, where each object is one row and each key in the object is a field name. For example:

[
  { "InvoiceID": 1001, "CustomerName": "Acme Corp", "Amount": 1500.00 },
  { "InvoiceID": 1002, "CustomerName": "Widget Co", "Amount": 750.50 },
  { "InvoiceID": 1003, "CustomerName": "Acme Corp", "Amount": 320.00 }
]

Articles reads the first object to determine the field names and types, creates the in-memory table structure, then loads all rows. Field types are inferred from the JSON values — numbers become numeric fields, strings become string fields, boolean values become boolean fields.

If the API returns a single object rather than an array, Articles wraps it in an array so it appears as one row in the table.

Master Detail with REST Table

REST Table supports master-detail linking against another dataset. The entire REST data is loaded once when the report starts. As the master dataset moves through its rows, the REST Table filters its in-memory data to show only the matching rows — no additional API calls are made.

This is different from FD Query master-detail where the detail query re-runs against the database for each master row. REST Table loads all data upfront and filters in memory.

To set up master-detail with REST Table:

  1. Set MasterSource to the master dataset (an FD Query, FD Table, or another dataset)
  2. Set MasterFields to the field name in the master dataset — for example CustomerID
  3. Set DetailFields to the matching field name in the REST Table — for example CustomerID

For multiple linking fields, separate each with a comma and make sure the order matches between MasterFields and DetailFields:

MasterFields: CompanyID,CustomerID
DetailFields: CompanyID,CustomerID

Changing the URL at Runtime from Script

You can change the URL from script before the report opens — useful when the URL depends on a user selection or report variable. Do this in the REST Table’s OnBeforeOpen event:

procedure RESTTable1BeforeOpen(Sender: TfrxComponent);
begin
  RESTTable1.URL := 'https://api.example.com/invoices?customerid=' +
    FDQueryCustomers.FieldByName('CustomerID').AsString;
end;

After changing the URL in OnBeforeOpen, Articles fetches the new URL automatically when the dataset opens.

Events

OnBeforeOpen
Fires before Articles fetches the URL. Use this to change the URL, set authentication values, or perform any setup that needs to happen before the data is fetched. The Sender parameter is the REST Table component itself.

OnAfterOpen
Fires after Articles has fetched the URL and loaded the data successfully. Use this to read the record count, apply a filter, or perform any action that depends on the data being available.

OnError
Fires when an error occurs during the fetch. The ErrorMsg parameter contains the error description. Use this to handle errors gracefully — for example logging the error or showing a user-friendly message — instead of letting Articles raise an exception. If OnError is not set, Articles raises an exception on error.

Example OnError handler:

procedure RESTTable1OnError(Sender: TfrxComponent; const ErrorMsg: String);
begin
  // Log the error and continue — report will show empty data
  ShowMessage('Could not load REST data: ' + ErrorMsg);
end;

Common Problems

RefreshData shows “HTTP 401: Unauthorized”
The API requires authentication but AuthType is set to atNone, or the credentials are wrong. Check AuthType and the corresponding credential properties. For OAuth2 check that TokenURL, ClientID, and ClientSecret are all correct.

RefreshData shows “HTTP 404: Not Found”
The URL is wrong. Check the URL for typos, missing path segments, or incorrect query parameters. Click the URL property to open the editor and verify the full URL.

No fields appear after RefreshData
The API returned an empty array or a response that Articles could not parse. Check LastError for details. Also verify that the API returns a JSON array of objects — other response shapes such as a wrapped response object may not parse correctly.

The report shows no data at runtime even though RefreshData worked at design time
RefreshData caches the data in the designer. At runtime Articles fetches the URL fresh. If the runtime environment cannot reach the API — due to network restrictions, firewall rules, or a different server address — the fetch will fail silently if OnError is not set. Add an OnError handler to see what is happening.

Master detail filtering shows wrong rows
Check that MasterFields and DetailFields have the same number of entries and that they are in the same order. Also check that the field names match exactly including case. The filter is case sensitive for string fields.

OAuth2 token keeps expiring mid-report
Articles retries once with a fresh token when a 401 response is received. If the token lifetime is very short and multiple retries are needed, consider using a longer-lived token or switching to Bearer token authentication with a manually managed token.

The URL contains special characters that are being mangled
URL encode any special characters in query parameter values — for example spaces become %20, ampersands in values become %26. Build the URL carefully in script if it contains dynamic values from field data.

Related Pages

FD Components Overviewns

FD Query

Master Detail Setup

  • The component expects the REST endpoint to return a JSON array of objects. Each object becomes one row and each key becomes a field.
  • All data is loaded into memory at once. For very large datasets, consider adding filters to the URL as query string parameters to reduce the number of rows returned by the API.
  • Field names in the Filter property are case-sensitive and must match exactly as they are returned by the API.
  • OAuth2 support uses the client credentials grant type only.
  • Setting Active to True at design time makes a live call to the URL. Make sure you have network access to the API when working in the designer.