Show: Delphi C++
Display Preferences

REST Debugger Tool

From RAD Studio
Jump to: navigation, search

Go Up to REST Debugger

Tools > REST Debugger


The REST Debugger is a tool for making ad hoc requests. The TRESTDataSetAdapter and TClientDataSet components convert the JSON representation into a dataset.

With this tool, you can use different authentication methods to connect to services such as Google API or Twitter. You can send a request to the specified service and view the response.

The Request Pane

Request

Use the Request tab to specify the TRESTClient and the TRESTRequest properties.

Item Description

Method

Lists the TRESTRequest methods, as follows:
POST--submits data to be processed to the TRESTRequest resource.
PUT--updates data for the TRESTRequest resource.
GET--requests data from the TRESTRequest resource.
DELETE--deletes the data from the TRESTRequest resource.
PATCH--patches the data on the TRESTRequest resource by updating only the pairs that are sent within that PATCH body.

URL

Specifies the BaseURL property of the TRESTClient. The BaseURL property is the first half of the complete request-url.

Tip: Press ENTER in this field to send your request. See Send Request.

Content-Type

Specifies the ContentType property of the TRESTRequestParameterList.

Custom body

Specifies the CustomBody property of the TRESTRequestParameterList.

Parameters

Use the Parameters tab to define the actual action to be executed on the service and the TRESTRequest parameters.

Item Description

Resource

Specifies the Resource property of the TRESTRequest.
The Resource property is the second half of the full request-url and represents the actual query-string.

Request Parameters

Specifies the TRESTRequest parameters. There are different parameters types:
Header Parameters--have the form of key=value and will be embedded into the HTTP header of the request.
Post/Get Parameters--have the form of key=value. For HTTP post requests, the Post Parameters will be embedded into the request body. For HTTP get requests, the Get Parameters will be embedded into the URL as part of the query string.
Body Parameters--consist of only one value and are integrated in the TRESTRequest body.
URL Segment Parameters--have the form of key=value and their value is appended to the HTTP URL prior to the query string of the request. Multiple URL Segment Parameters are delimited by a backslash (\).
Cookie Parameters--have the form of key=value and will be sent as cookie-values.

Add

Adds a new parameter to the TRESTRequest Parameter List. Specify the parameter type using the Kind ComboBox, the parameter name in the Name TComboEdit, and the parameter value in the Value TEdit.

Edit

Edits a parameter from the TRESTRequest Parameter List. Change the type, name, or value of the parameter selected.

Delete

Deletes the parameter selected from the TRESTRequest Parameter List.

Authentication

Authentication is required by most of the services. An authenticator is attached to the client and is automatically executed on each completed request.

Item Description

Method

Specifies the standard authenticators that are attached to the rest-clients.
NONE--is used when the service does not require an authentication. By default, the TRestClient Authenticator method is amNONE.
SIMPLE--mimics a basic authentication like an HTML form. TSimpleAuthenticator requires the values and the keys name of Username and Password.
BASIC--refers to the HTTP basic authentication. THTTPBasicAuthenticator requires the Username and the Password to be embedded into the HTTP header of the request.
OAUTH--is a method that implies user interaction. The application that is using TOAuth1Authenticator receives tokens from the service provider and it needs to use these tokens to access the service.
OAUTH2--receives tokens from the service provider and it needs to use these tokens to access the service. Compared with TOAuth1Authenticator, TOAuth2Authenticator relies on HTTPS for security and you do not have to sign a request anymore.

Username

Represents the AuthUsername property of the TRESTRequestParameterList. The Username TEdit is enabled for the simple and basic authenticators.

Password

Represents the AuthPassword property of the TRESTRequestParameterList. The Password TEdit is enabled for the simple and basic authenticators.

Username-key

Represents the AuthUsernameKey property of the TRESTRequestParameterList. The Username-key TEdit is enabled for the simple authenticator.

Password-key

Represents the AuthPasswordKey property of the TRESTRequestParameterList. The Password-key TEdit is enabled for the simple authenticator.

Client-ID

Represents the ClientID property of the TRESTRequestParameterList. The Client-ID TEdit is enabled for the OAUTH and OAUTH2 methods.

Client-Secret

Represents the ClientSecret property of the TRESTRequestParameterList. The Client-Secret TEdit is enabled for the OAUTH and OAUTH2 methods.

Access-token

Represents the AccessToken property of the TRESTRequestParameterList. The Access-token TEdit is enabled for the OAUTH and OAUTH2 methods.

Request-token

Represents the AccessTokenSecret property of the TRESTRequestParameterList. The Request-token TEdit is enabled for the OAUTH and OAUTH2 methods.

OAuth-Assistant

Opens a new window that has all the parameter values for OAUTH or OAUTH2 methods. In this newly opened window, there are fields that are not present in the main page of Authentication, so you can use different services, as Google or Twitter.

Connection

Use the Connection tab to specify the Proxy properties of TRESTClient.

Item Description

Use Proxy Server

Check the Use Proxy Server TCheckBox or leave the checkbox unchecked to specify if the TRESTClient handles proxy servers.

Proxy Server

Specifies the ProxyServer property of the TRESTClient.

Proxy Port

Specifies the ProxyPort property of the TRESTClient. By default, the value of ProxyPort is 0.

Username

Specifies the ProxyUsername property of the TRESTClient.

Password

Specifies the ProxyPassword property of the TRESTClient.

Request Buttons

Item Description

Send Request

Configures the Proxy Server if needed, defines the BaseURL and the Resource properties, and the TRESTRequest method. Click the Send Request button to execute TRESTRequest and show the response.

New Request

Resets the Request, Parameters, Authentication, and Connection page fields to their default values.

Load Request

Uses the TOpenDialog component to load the properties values for TRESTClient, TRESTRequest, or TRESTResponse from the file selected.

Save Request

Saves into a file the properties values of the TRESTClient, TRESTRequest, or TRESTResponse component.

Copy Components

Copies the TRESTClient, TRESTRequest, and TRESTResponse components to the clipboard. You can copy these components to the clipboard, and then paste them to the Form Designer.

The Response Pane

Use the Response page to read the returned data from the service through the TRESTResponse class.

There are three labels within the TGroupBox that show the response received from the service: the LastRequest URL and the LastRequest Stats labels are right on the top of the TGroupBox, while the Proxy State label is at the bottom of the TGroupBox.

Item Description

LastRequest URL

Displays the BaseURL property of the TRESTClient.

LastRequest Stats

Contains information about:

  • Response status--displays the StatusCode, StatusText, and ContentLength properties of the TRESTResponse.
  • Execution performance--displays timing information:</li>
    • PreProcessingTime : time from the start of the execution until the request is handed over to the the actual http client and sent to the server.
    • ExecutionTime : time since the request is sent to the server and until the response is received.
    • PostProcessingTime : time from receiving the server response until all post processing work is done (including JSON parsing).
    • TotalExecutionTime : the total execution time - the sum of PreProcessingTime, ExecutionTime, and PostProcessingTime.

Proxy State

Specifies if the ProxyServer is enabled or not.

Headers

The response header contains pairs of (key=value) and has information such as date, size, and type of file that the server sends to the client, and also data about the server itself.

The HTTP header fields retrieved by the server differ from an API to another.

Item Description

ResponseHeader

Displays the Headers property of the TRESTResponse.

Body

The response holds all the returned data from the service. The data includes the HTTP status code, error messages (if these exist), and the returned JSON data.

The response data can be accessed using one of the properties: Content, JSONValue, or RAWbytes.

Item Description

LabelJSON

Specifies if:

  • the content has a JSON representation or not.
  • the JSON root element is an invalid one.

JSON Root Element

Represents the RootElement property of TRESTResponse. Insert the needed root element into JSON Root Element TClearingEdit.

ResponseBody

Displays all the returned data from the service, that are right after the header.

Apply

Limits the contents of the response body shown, based on the RootElement property.

Tabular Data

A JSON formed response of a service can be transformed into any TDataSet-descendant class with a dataset adapter.

Each JSON object will be a new record in the dataset. The properties of the JSON object(s) will typically form the columns of the dataset.

Item Description

StringGrid

Shows the response organized as a dataset.

Previous

Installing the REST Debugger

Next

Using the REST Debugger

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance