as of release 3.27

prior to release 3.27

Function

This object is used to make a REST call to a web service.

Programming Experience Required

Note: you will require programming experience to use this object. jtel does not provide developer support as part of the standard support contract.

The object can perform the following type of REST calls:

  • GET
  • POST
  • PUT
  • DELETE

It is possible to specify parameters, which are coded in the URL. Also it is possible to specify additional headers which will be sent with the http headers when the REST call is made.

When POST or PUT operations are performed, data can be specified which is sent in the content of the http request.

When the call returns, the headers from the response are provided as variables which can be used in the application at a later step. The response body is parsed if valid XML or JSON, and is also provided as variables. It is possible to specify a prefix for the result (which includes the headers), and a separate prefix for the content variables provided.

Parameters

ParameterPurpose

Object Name

The name of this object instance

Request Method

Choose the http request method to be used. GET, POST, PUT and DELETE are supported.

Headers

Any number of headers can be specified and will be sent with the http request.

Headers must be specified separated by \n, if more than one header will be used.

For example:

my-header-1: value1\n
my-header-2: value2
Parameters

Parameters are passed at the end the URL, in the form:

http(s)://url?param1=value1&param2=value2

The parameters will automatically be URL encoded as required.

DataData is only required for POST or PUT operations. The data is passed as defined by the Content-Type parameter.
Content-Type

This parameter is passed as the http header "Content-Type", and defines how the data included in the POST or PUT request will be encoded.

Currently supported are:

application/json
application/x-www-form-urlencoded
text/plain
text/xml
Variable Prefix Content

If the web service returns content with the http response, then this will be provided as follows:

  • In the variable:

    $<VariablePrefixContent>.responseData
  • If valid XML, then as variables of the form:

    $<VariablePrefixContent>.xmlStructure.xmlFieldName

  • If valid JSON, then as variables of the form:

    $<VariablePrefixContent>.jsonStructure.jsonFieldName

The exact format provided will depend on the exact structure returned. You should use the Variable Dump Object to examine the exact variables which are parsed.


Example:

ItemValue
Variable Prefix Content
myContent
Returned Content
{ "token": "QpwL5tke4Pnpja7X" }
Provided Variables
$myContent.responseData = { "token": "QpwL5tke4Pnpja7X" }
$myContent.token = QpwL5tke4Pnpja7X

Variable Prefix Result

The headers and the http status line and status code are stored in variables prefixed with the value provided here.

The following variables are provided automatically (assuming a valid http response):

  • $<VariablePrefixResult>.httpResponseCode - the http response code
  • $<VariablePrefixResult>.httpResponse - the http response line

Example:

ItemValue
Variable Prefix Result
myResult
http Status Line
HTTP/2 200 OK
Headers
content-type: application/json; charset=utf-8
set-cookie: __cfduid=d071fc20b4ada453375f3189252f1559d1556981085; expires=Sun, 03-May-20 14:44:45 GMT; path=/; domain=.test.com; HttpOnly
Provided Variables
$myResult.httpResponseCode = 200
$myResult.httpResponse = HTTP/2 200 OK
$myResult.content-type = application/json; charset=utf-8
$myResult.set-cookie = __cfduid=d071fc20b4ada453375f3189252f1559d1556981085; expires=Sun, 03-May-20 14:44:45 GMT; path=/; domain=.test.com; HttpOnly

Outputs

Output

Used when ...

200 OK

A 200 OK response was received from the http Server.

OtherAny other response was received from the http Server.
ErrorAn error occurred. No response, or an incorrect response was received from the http Server.

Variables Provided

Prefix is replaced with the prefix specified in the object definition.

Variable

Contains

resultPrefix.httpResponseCode

The http response code.

resultPrefix.httpResponse

The http response.

resultPrefix.responseDataThe http content.
resultPrefix.commandThe CURL command used for reference / debugging.
resultPrefix.*

Other http headers provided by the web service.

contentPrefix.*Parsed variables from a valid JSON or XML response.

Release

3.14 FROM 04.05.2019

  • No labels