HTTP Library that makes HTTP requests simpler and more human-friendly.
Provides functionality for convenient REST API communication including the following features:
* Utilizing HTTP methods: GET, POST, PUT, DELETE
* Saving endpoint configuration in static data (via DBISYS)
* Establishing connection without static settings (via InitializeWithURL)
* Managing security settings per endpoint (see documentation for AUTMOD)
* Logging (if activated) all verbose information (request, response, debug data)
How to use it:
1. To have endpoint settings stored - add instance of RSTMOD to DBISYS\SYSGRP with object name related to endpoint.
E.g: RSTMOD : RSTXLS
2. Add description of the endpoint via SYSTBL to codetable RSTSRV. E.g:
RSTXLS - Excel Handler
3. Neccessary panels for configuration will appear automaticaly in DBISYS. Configure endpoint and save settings
4. Add the same instance (i.e. RSTMOD : RSTXLS) to the place where the API communication should take place
5. To have HTTP-communication with configured endpoint - the following commands to be executed:
- Load settings (mandatory to call before any other command)
RSTXLS.Initialize
- Add nodes to URL:
RSTXLS.AddToUrl( <url node> )
- Add parameters to URL:
RSTXLS.AddParToUrl( <name>, <value> )
- Add parameters to Header of the request
RSTXLS.AddParToHeader( <name>, <value> )
- Set request body with given content
RSTXLS.SetRequest( <request_body> )
- Perform given HTTP request using the previously set parameters:
RSTXLS.RestPost\\ if ErrorCode > 0 then\\ # necessary error handling. Standard HTTP errors are reraised with +1000. I.e. HTTP error 404 will be raised as 1404.\\ endif\\
- Retrieve response from HTTP call
$response = RSTXLS.GetResponse
If the format is JSON, then the following call is valid to start working with JSON:
$handle = TDJsonInit( RSTXLS.GetResponse )
Property | YES/NO |
---|---|
Single page frame | No |
Show toolbar | No |
Show menu | No |
Show statusbar | No |
Show hint | No |
Fit panel size | No |
Name | Description | Data Type | Len | Dec. | View lines | View type | Inst. | Visible | Codetable |
---|---|---|---|---|---|---|---|---|---|
PANSTA | Panel Status 'E'dit 'I'nfo | Text | 1 | 1 | Edit | Yes | Public | ||
NAME | Name | Text | 100 | 1 | Edit | Yes | Public | ||
STMIN | Input | Stream | 1 | 0 | Source | Yes | Private | ||
STMOUT | Output | Stream | 1 | 0 | Source | Yes | Private | ||
STMDBG | Debug | Stream | 1 | 0 | Source | Yes | Public | ||
FMT | Format | Text | 4 | 1 | Edit | Yes | Public | Embedded | |
SRVNAM | Rest Instance Name | Text | 10 | 1 | Edit | Yes | Private | ||
URL | Endpoint URL | Block | 64 | 32 | 4 | Block | Yes | Private | |
PARURL | Parameters for URL | Block | 64 | 32 | Block | Yes | Private | ||
CURURL | Current URL for calling | Block | 64 | 32 | Block | Yes | Private | ||
SRVPNT | Parent Module of REST Instance | Text | 10 | 1 | Edit | Yes | Private | ||
LBLVBS | Label for Verbose Folder | Text | 100 | 1 | Edit | Yes | Private | ||
HEADER | Header for request | Stream | 1 | 1 | Source | Yes | Private | ||
DBGSAV | Save Debug Info | Text | 1 | 1 | Edit | Yes | Public | ||
REQSAV | Save Request | Text | 1 | 1 | Edit | Yes | Public | ||
RESSAV | Save Response | Text | 1 | 1 | Edit | Yes | Public | ||
APINAM | API Name | Text | 30 | 1 | Edit | Yes | Public | ||
HDROUT | Header for response | Stream | 1 | 1 | Source | Yes | Private | ||
TSTFLG | Test Mode | Text | 1 | 1 | Edit | Yes | Public | ||
TSTHTPSTA | Test Http Response Status Code | Text | 3 | 1 | Edit | Yes | Public | HTPSTA | |
TSTHTPBODY | Test Http Response Body | Stream | 1 | 0 | Source | Yes | Public | ||
TSTHTPHDR | Test Http Response Header | Stream | 1 | 0 | Source | Yes | Public | ||
HTPSTA | Http Response Status Code | Numeric | 3 | 0 | Edit | Yes | Public | ||
HTPSTATXT | Http Response Status Text | Text | 80 | 1 | Edit | Yes | Public | ||
APITYP | API Type | Text | 8 | 1 | Edit | Yes | Public | Embedded | |
OLDAPITYP | Old API Type | Text | 8 | 1 | Edit | Yes | Private | ||
CNTLEN | Http Header: Content Length | Text | 1 | 1 | Edit | Yes | Private |
Contains content of request.
To set request - use method SetRequest
Contains content of response.
To get response - use method GetResponse
Code | Text |
---|---|
XML | text/xml |
JSON | application/json |
TXT | text/plain |
SOAP | application/soap+xml |
URL for REST base endpoint
Maximum size 2048
To add nodes to URL - use AddToURL To add parameters to URL - use AddParToURL To get full URL - use GetURI
Includes parameters of URL
To add parameter - use function AddParToUrl
Contains current URL.
To get current URL - use GetURI
Indicates parent module of current instance of RSTMOD. Used as security sontext
Contains header for the request.
To set header - see method AddParToHeader
When set to non-empty - debug info after API call can be found in stream DBGSTM and saved in debug folder
For the folder - see function SYSTDC.GetVerboseFolder
When set to non-empty - request of API call is saved to debug folder.
For the folder - see function SYSTDC.GetVerboseFolder
When set to non-empty - response of API call is saved to debug folder.
For the folder - see function SYSTDC.GetVerboseFolder
PCH-717 Contains header for the response.
To get header parameter - see method GetHttpHeaderParameter
Contains content of http response body
PCH-717 Contains content of http response header
Code | Text |
---|---|
REST | REST API |
SOAP11 | SOAP API v1.1 |
SOAP12 | SOAP API v1.2 |
Panel | Type | Description |
---|---|---|
CONFIG | FramePanel | REST API Configuration |
RESTCFG | FramePanel | REST API configuration |
TESTCFG | FramePanel | Test configuration |
Property | Value |
---|---|
Width | 788 |
Height | 528 |
Popup position-X | 0 |
Popup position-Y | 0 |
Visible | No |
Read only | No |
Show toolbar | No |
Instanciated | Yes |
Popup panel | No |
Global | No |
Property | Value |
---|---|
Width | 788 |
Height | 298 |
Popup position-X | 0 |
Popup position-Y | 0 |
Visible | No |
Read only | No |
Show toolbar | No |
Instanciated | No |
Popup panel | No |
Global | No |
Property | Value |
---|---|
Width | 788 |
Height | 528 |
Popup position-X | 0 |
Popup position-Y | 0 |
Visible | No |
Read only | No |
Show toolbar | No |
Instanciated | Yes |
Popup panel | No |
Global | No |
Rule | Name | Additional |
---|---|---|
function | GetHttpHeaderParameter | text method |
function | GetResponse | text method |
function | GetResponsePayload | text method |
function | GetURI | text method |
sub | AddParToHeader | method |
sub | AddParToUrl | method |
sub | AddToURL | method |
sub | Initialize | method |
sub | InitializeWithURL | method |
sub | LoadSettings | method |
sub | LoadSettingsCus | method |
sub | Reset | method |
sub | RestDelete | method |
sub | RestGet | method |
sub | RestPost | method |
sub | RestPut | method |
sub | SaveSettings | method |
sub | SaveSettingsCus | method |
sub | SetRequest | method |
This method returns content of response from the previous HTTP call
Returns complete URI of the endpoint including all parameters and added nodes
Adds pair “ArgPar”: “ArgValue” to the header of REST call
ArgPar - name of parameter
ArgValue - value of the parameter
Adds parameter + value to URL for REST API calling
Corresponding functions: RestGet, RestPost, RestPut, RestDelete, AddToURL
Adds node to URL
Corresponding functions: RestGet, RestPost, RestPut, RestDelete, AddParToURL
Initialize instance of RSTMOD with statically defined settings
Settings are stored in AppIniFile under section named as instance of RSTMOD
Initialize RSTMOD with given URL
Calls for REST DELETE method
Errorcode must be checked afterwards
Result can be retrieved by method GetResponse
Corresponding functions: RestGet, RestPost, AddToURL, AddParToURL
Calls for REST GET method
Errorcode must be checked afterwards
Result can be retrieved by method GetResponse
Corresponding functions: RestPost, RestDelete AddToURL, AddParToURL
Calls for REST POST method
Errorcode must be checked afterwards
Result can be retrieved by method GetResponse
Corresponding functions: RestGet, AddToURL, AddParToURL
Calls for REST PUT method
Errorcode must be checked afterwards
Result can be retrieved by method GetResponse
Corresponding functions: RestGet, RestPost, AddToURL, AddParToURL
This method is used to set request for the upcoming HTTP call
ArgReq - content of request to be sent
Resets fields of RSTMOD to the state of initialization (without clearing the settings)
Might be useful in settings transactions to use settings not from ini-file but from current “online” settings
returns the value of the response http header parameter ArgPar
ArgPar: name of http header parameter
returns: value of http header parameter
This method returns the content of the functional body (payload data) of the response from the previous HTTP call
It strips away from the response all technical headers (control data)
Module class | Instance | Comment |
---|---|---|
ENCMOD | ENCMOD | |
AUTMOD | AUTMOD | |
SOAAPI | SOAAPI | |
SYSTDC | SYSTDC | |
SYSTDT | SYSTDT | |
SSNAPI | SSNAPI |