esi-http

esi-http offers the most simple interface to fetch data from external web servers.

Dependencies

library version inmation core library

esi-string

1.0.0

yes

esi-tool

1.0.0

yes

Available functions

All functions have to be called according to the ESI standard, using colons, e.g. lib:FUNCTIONNAME(params)

Documentation

QUERYDATA(pars)

This function executes one or multiple HTTP requests against a web server. It can either call a web site with no authentication, basic authentication or token-based authentication.

The data fetched from the web server is returned by the function either as a Lua table, a JSON document or native (as retrieved from the server). The latter two are of type string.

Scenario Mandatory Parameters

The HTTP server supports (or requires) no authentication.

URL

The HTTP server supports (or requires) basic authentication.

URL, USER, PWD

The HTTP server supports (or requires) token-based auhentication. In this case, QUERYDATA will use 'POST' commands to obtain the token and the data

HEADERFIELD, URL, USER, PWD

QUERYDATA Parameters

pars (table, required)

The pars table must supply all mandatory parameters according to the call type described above.

Field Data Type Meaning

ENC

string

the encoding to be used. The current version only supports JSON. As such, you may either supply "JSON" or simply ommit the field.

HEADERFIELD

string

The field in the POST header, which will be used to transmit the authentication token (token-based authentication only)

URL

string

the URL to invoke with the HTTP 'GET' command. This is either the single call when operating in simple mode, or the second call after the authentication token has been retrieved in two-step authenticating mode.

QUERYDATA returns

Value Data Type Meaning

#1

boolean

Success indicator. If this is true, the following parameter will contain the data in the desired format, an error string otherwise

#2

variant

The data which was returned by the server in the desired format (either table or string), or, in case the first return value is false, the error message as a string