ExecuteHttpRequest

This function executes an HTTP request. It supports HTTP methods GET, POST, PATCH, PUT and DELETE.

The HTTP response is cached in memory. A response consists of a status code, a number of headers and a body, any of which can be queried by using the corresponding TurboIntegrator functions: HttpResponseGetStatusCode, HttpResponseGetHeader, and HttpResponseGetBody.

The Planning Analytics Engine only keeps one HTTP response at a time. A new successful HTTP request execution update and overwrites the cached response.

The Planning Analytics Engine only keeps the first 100 KB of a response body and discards the rest. This prevents running out of evaluation memory for strings.

For convenience, the engine reuses the cookie it found in the previous responses in new requests when the Cookie header is absent.

Syntax

ExecuteHttpRequest(method, URL, option1, option2, ...);

Argument

Description

method The method of the HTTP request. Supported methods are
URL The URL where you want to execute the request. The URL must use the HTTP or HTTPS protocol.
option1, option2, ... You can use these options in the request:
-u user
The basic user credential
-h header
The request header. A request can have multiple headers.
-d body
The request body. When started with an @ character, the body will be read from the file having the name found following the @ character.
-o filename
The file to which the response is written.
-c certificate_file
A custom CA certificate file.
-k
Instructs the server to not verify the TLS certificates.

Example

# Get the cube rules from a remote TM1 server
ExecuteHttpRequest(
  'GET',
  'https://ibmcloud:11838/api/v1/Cubes(''A'')/Rules',
  '-u admin:',
  '-o response.json'
  '-c tm1_cert.perm' );

rules = HttpResponseGetBody();

# Update the rules of a cube on a remote TM1 server
ExecuteHttpRequest(
  'PATCH',
  'https://ibmcloud:11838/api/v1/Cubes(''A'')',
  '-u admin:',
  '-h Content-Type:application/json',
  '-d { "Rules" : "" }',
  '-k' );
  
status_code = HttpResponseGetStatusCode();