Skip to content

TTMSFNCRESTClient

Usage

TTMSFNCRESTClient provides the abilitiy to easily configure and test your HTTP requests. The configuration of the component can be tested in design-time (in Delphi), this will retrieve the body of the response as text.

TTMSFNCRESTClient_Basic_Editor

If you have the TMS FNC UI Pack installed, you can check TTMSFNCRESTClientEditor for an editor where you can configure the request as well.

The component can be used together with REST Insight, where you have the abilitiy to save the request and load the request in your TTMSFNCRESTClient.

Remark

The component is only available on VCL and FMX for the moment.

Properties

TTMSFNCRESTClient_Properties

Property name Description
Request: TTMSFNCRestClientRequest The configuration of the request that will be executed.
ExecutedRequests: TTMSFNCRestClientExecutedRequests Collection of all the requests that have been executed.

Methods

Method name Description
Clear Resets all the properties of the current request. And removes all of the executed requests.
ExecuteRequest Executes the current request. (Can take a TTMSFNCRESTClientGetResponseCallBack as parameter.)
ExecuteRequestWithResultString Executes the current request with the result type set to String. (Can take a TTMSFNCRESTClientGetResponseStringCallBack as parameter.)
ExecuteRequestWithResultStream Executes the current request with the result type set to Stream. (Can take a TTMSFNCRESTClientGetResponseStreamCallBack as parameter.)
ExecuteRequestWithResultFile Executes the current request with the result type set to File. (Can take a TTMSFNCRESTClientGetResponseFileCallBack as parameter.)
GetExecutedRequestByURL(AURL: string) Retrieves the last executed request based on the URL.
LoadRequest Opens a dialog to load a .json file that was saved from REST Insight or the TTMSFNCRESTClientEditor.

Events

Event name Description
OnRequestURLChanged Event triggered when the URL of the request was changed.
OnRequestHeadersChanged Event triggered when the headers of the request were modified.
OnRequestResponseRetrieved Event triggered when a response is retrieved. This contains the result string, stream and file.
OnRequestResponseStringRetrieved Event triggered when a response is retrieved with the result type set to String. This contains the result string.
OnRequestResponseStreamRetrieved Event triggered when a response is retrieved with the result type set to Stream. This contains the result stream.
OnRequestResponseFileRetrieved Event triggered when a response is retrieved with the result type set to File. This contains the result file and file size.

TTMSFNCRestClientRequest

Request Properties

Property name Description
Async: Boolean Send the request asychronous or hold the application until a response is retrieved.
AuthorizationOptions: TTMSFNCRESTClientAuthorizationOptions Type and credentials for the authentication of the HTTP request.
Headers: TTMSFNCRESTClientRequestHeaders Collection of the headers with their Key and Value.
Host: string Identifies the host that holds the resource. (Important to split the host and the path.)
Method: TTMSFNCCloudBaseRequestMethod The type of request. (The default value is GET.)
Path: string Refers to the exact location of a page, post, file, or other asset.
Port: Integer Identify a connection endpoint and to direct data to a specific service. (The value 0 defaults to the HTTPS port 443.
PostData: string Data enclosed in the body of the request message.
Query: string The parameters added to the URL. (Also sets the 'QueryParameters')
QueryParameters: TTMSFNCRESTClientRequestQueryParameters Collection of the parameters with their Key and Value. (Also sets the 'Query')
ResultFile: string The path to where the file should be stored if the ResultType is set to rrtFile.
ResultType: TTMSFNCCloudBaseRequestResultType Identify the type of response that is retrieved. (The default value is rrtString.)
URL: string The URL for the request. (This will set all of the other linked properties as well.)

Request Methods

Method name Description
Clear Resets all of the properties.
ExecuteRequest Executes the request. (Can take a TTMSFNCRESTClientGetResponseCallBack as parameter.)
ExecuteRequestWithResultString Executes the request with the result type set to String. (Can take a TTMSFNCRESTClientGetResponseStringCallBack as parameter.)
ExecuteRequestWithResultStream Executes the request with the result type set to Stream. (Can take a TTMSFNCRESTClientGetResponseStreamCallBack as parameter.)
ExecuteRequestWithResultFile Executes the request with the result type set to File. (Can take a TTMSFNCRESTClientGetResponseFileCallBack as parameter.)
GetMethodString Retrieves the method of the request as text.

TTMSFNCRestClientResponse

The TTMSFNCRestClientResponse is a property that is used in the executed requests. It holds the information that is retrieved from the server.

Response Properties

Property name Description
ResponseCode: Integer Indicates the status of the response to the request.
ResponseHeaders: TTMSFNCRESTClientRequestHeaders Collection of the headers with their Key and Value.
ResponseSize: Integer The size of the body.
ResponseString: string The body of the response as text.
ResponseSuccess: Boolean Indicates whether the request has been successfully completed.
ResponseTime: Integer The time it takes in milliseconds for the server to answer the request.