NG ConnectionPack Guide


API Explorer


NG ConnectionPack provides visual tool, called API Explorer, which allows to test all supported services, by executing corresponding REST operations. API Explorer can be used directly inside Delphi IDE. API Explorer window can be shown by clicking on the corresponding menu item in Tools main Delphi menu:

 

clip0001

 

Interface overview

 

The main page of API explorer window shows supported services list:

 

clip0002

 

Double clicking on the service item will navigate to Service's page, where its operation list is shows:

 

clip0003

 

Double clicking on operation item will navigate to operation execution page:

 

clip0004

 

Dark theme:

 

clip0038

 

 

On this page, operation request parameters can be set up and the operation can be executed. After operation execution, the resulting data will shows at the bottom of the page. If operation execution fails, an exception information will shows instead. Please read below about request editor usage.

 

Authentication options

 

Before any of REST operation can be executed, authentication options should be specified for the corresponding service. As can be seen from above images, the link to authentication options page is shown at the service page and, as well, at operation execution page. Clicking on the link will navigate to service options page:

 

clip0005

 

ClientID and Secret codes of the service should be set to appropriate values, as well, as Redirect URL. Please read more here. Scopes can be also adjusted. Option parameters are stored in Windows registry along with current access token, so there no requirement to logging in every time.

 

Request editor

 

Request parameters on operation execution page are shows with JSON like syntax in a special editor control:

 

clip0006

 

The editor allows to overview provided request parameters and edit their values. Unspecified (null) properties are shows in gray color. To provide a value for primitive property, just click on the value text and type the value in shown in-place editor. To provide a value for array, map or object properties, select property line and press Insert button, or double click property line; array, map or object instance will be created as a result. To clear property value, select property line and press Ctrl+Delete key.

 

Since data objects usually declare a lot of properties, unspecified (null) properties is not shown by default. However, initially, unspecified (gray) properties are shown for root request object itself. To show unspecified properties, Insert Mode should be activated for this object:

 

Select the line, after which unspecified properties need to be shown. This can be one of already object property line or the beginning line of the object itself. Press Insert key or double click object beginning line to show all unspecified properties after selected line.

Select the line, before which unspecified properties need to be shown. This can be one of already object property line or the ending line of the object itself. Press Shift+Insert key or double click object ending line to show all unspecified properties before selected line.

After editing values of requires properties press Escape key to cancel Insert Mode and hide all unspecified properties; now configured request parameters can be seen in a more compact way.

 

Insert Mode should be turned on for each object separately. However, Escape key turn off Insert Mode for all objects at once. Insert Mode example:

 

clip0007

Compacted mode, with hidden unspecified properties look like:

 

clip0008

 

The editor supports NG ConnectionPack all data types. Numbers and string values can be entered as usual, Boolean values support True and False string literals, and as well can be specified as 0 or 1 numbers. Date and Date-Time values should be specified according to ISO 8601 format, like 2018-01-01T12:00:00Z. Upload and Download values are handled in a special way, please read below.

 

Upload and download

 

If an operation require to upload stream data, its request object declares property of NGUpload type. For example, data property in TNGGDrive.CreateFileUpload operation request. In API explorer this property is shows as a single line, where uploading file path should be specified. As well, double clicking on the line, will show standard Open file dialog:

 

clip0009

 

If an operation requires to download stream data, its request's Execute method takes NGDownload parameter. In API Explorer, special text editor will be shown after request parameter editor to specify file path for downloading into:

 

clip0010

 

Clicking on select file label will open standard Save file dialog.

 

Currently, uploads and downloads can be performed only from/to files; there no other built-in content editor. However, downloaded file can be easily opened in Windows File Explorer, using the corresponding button, which will appear after successful operation execution.

 

Exploring user components

 

API Explorer also allows to explore user's components, which are components, placed on the form or data-module at design-time. This feature allows developers to test REST API with already defined in Object Inspector application settings: ClientId, Secret and Scopes. This can be done by right-clicking the component icon and selecting Show In API Explorer menu item:

 

clip0011

 

After that, the component will be added to API Explorer services list, so its operations can be executed:

 

clip0012

 

API Explorer does not remember users components list, so, the component reside in the list only until its parent form is not closed in IDE or the component is removed from the form. Also, in current version, API Explorer does not save access token for user's components.