createHTTPRequest()

Function that creates a new ScriptableHTTPRequest object, in order to issue REST/AJAX calls to external servers.
This feature allows the data mapping process to complement its extraction process with external data, including data that could be provided by an HTTP process in Workflow, for instance a process that retrieves certain values from Workflow’s Data Repository. Another possible use is to have a Postprocessor that writes the results of the extraction process to a file and immediately uploads that file to a Workflow process.

The returned ScriptableHTTPRequest has a selection of the properties and methods of the standard JavaScript XMLHTTPRequest object (see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest). Supported properties and methods are listed below.

It is not possible to use the async mode, which can be set via the open() function of the ScriptableHTTPRequest (see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open) in a data mapping configuration. Async-related properties and methods of the ScriptableHTTPRequest object - for example .onreadystatechange, .readyState and .ontimeout - are not supported.
The reason for this is that by the time the response comes back from the server, the DataMapper script may have finished executing and gone out of scope.
Supported properties
  • response
  • status
  • statusText
  • timeout (ms). Default: 1 minute.
Supported methods
create() Creates a new instance of ScriptableHTTPRequest.
  • open(String method, String url, String user, String password)
  • open(String verb, String url, String userName, String password, String[] headers, String[] headervalues, String requestBody)
Opens a HTTP request.
If you don't use a user name and password, pass empty strings: request.open("GET",url,"","");
  • send()
  • send(String requestBody)
Sends an HTTP request and returns the HTTP status code. Blocked call.

getResponseHeader(String header)

Gets the ResponseHeader by name.

getResponseHeaders()

Returns the full response headers of the last HTTP request.

getRequestBody() Gets the HTTP request body (for POST and PUT).
setRequestHeader(String requestHeader, String value)

Adds an additional HTTP request header.

getResponseBody() Returns the full response body of the last HTTP request.
setRequestBody(String requestBody) Sets the HTTP request body (for POST and PUT).
getPassword() Gets the password for HTPP basic authentication
setPassword(String password) Sets the password for HTPP basic authentication

getTimeout()

Gets the time to wait for the server's response

setTimeout(int timeout)

Sets the time (in ms.) to wait for the server's response.

getUsername() gets the username for basic HTTP authentication.
setUsername(String userName) sets the username for basic HTTP authentication

abort()

Aborts the request.