/
REST_SERVICE ()

REST_SERVICE ()

REST_SERVICE(endpoint, [parameters])

API Version

2.8.1 and higher

Invokes an external service and stores the response

The invocation to the service is done using HTTP POST

The parameters must be passed in Application/json format

The response expected from the service must be a JSON object and have a predefined format as follows:

{ "result": "value returned by the service", "error": nil }

where:

  • result: is the result generated from the service (if any)

  • error: is a message informing about any possible error occurred during the execution of the service.

Input Parameters

Parameter

Type

Default

Required

Description

Parameter

Type

Default

Required

Description

endpoint

String

 

Yes

The endpoint can be:

  • A fully qualified URL (e.g. https://api.service.com/srv_function)

  • A relative URL. In this case, the function will assume that the base path of the URL is the internal “services” folder of the server instance. For example, if the value my_service/srv_function is provided and the server is configured so that the URL for internal calls is http://localhost, then the endpoint used will be http://localhost/services/my_service/srv_function.
    The internal URL is defined in the configuration parameter WS_LINK_LOCAL (see WEB SERVICES CONFIGURATION )

parameters

JSON

 

No

Parameters sent to the service

Return value

The value returned by the function is the result part of the response received from the service.

Execution

When the FORM containing the FORMULA is closed

 

Examples

Formula

Description

Formula

Description

REST_SERVICE(“https://api.service.com/srv_function“, {“param1”: “value1”, “param2”: “value2”})

The function will make a HTTP POST request to the endpoint https://api.service.com/srv_function with the specified parameters.

REST_SERVICE(“my_service/srv_function“, {“param1”: “value1”, “param2”: “value2”})

A partial URL has been specified as the endpoint. The function will asume that the base path is the subdirectory “services” of the internal URL endpoint (e.g. http://localhost/services/)

The internal URL is defined in the configuration parameter WS_LINK_LOCAL (see WEB SERVICES CONFIGURATION )



Related content