Skip to content

REST-RPC

logiccloud Control can call remote procedures over REST (REST-RPC) and map the results to your program variables. To do this, a new connection of type REST-RPC must be created.

Select Add REST-RPC connection and enter the endpoint information. After the connection has been created, select it in the outline tree to edit its configuration.

Connection settings:

  • Name: Name of the connection
  • Description: Description, optional
  • Base URL: base URL of the REST endpoint
  • Headers: request headers applied to every call
  • Authentication: authentication method — none, basic (username/password), bearer (token) or apikey (key + name + location: header, query or cookie)

The connection also exposes HTTP keep-alive / timeout tuning (max idle connections, idle-connection timeout, TLS handshake timeout, response-header timeout, follow-redirects and max-redirects) with sensible defaults.

A REST-RPC connection contains one or more endpoints, each describing a single remote call:

  • Path: path appended to the base URL
  • Method: HTTP method — GET, POST, PUT, PATCH or DELETE
  • Headers: per-endpoint request headers
  • Timeout: timeout (ms) for the call (default 15000)
  • Trigger / Trigger interval / Trigger variable: when the call fires — on change, grouped at an interval, or on demand via a trigger variable
  • Enable variable: variable that enables/disables the call
  • The request and response payload type and format are configured per endpoint (the response defaults to jsonObjectWithKey, the request to jsonDictionary).

Mappings belong to an endpoint and bind process variables to the request and/or response of the remote call.

  • Variable: the program variable that will be mapped
  • Data type: data type of the variable
  • Value path: path of the value within the JSON request/response payload (used by the jsonDictionary and jsonObjectWithKey formats)
  • Key path / Key name: key path and key name within the payload (used by the jsonObjectWithKey format)

Direction follows the payload it is attached to: variables mapped against the send (request) payload are written out to the remote call, while variables mapped against the receive (response) payload are read back into the runtime.

Besides the configured triggers above, a REST-RPC endpoint can be invoked directly from a POU with the RPC_CALL Structured Text extension. Pass the connection Name as TOPIC and the endpoint’s full URL (Base URL + Path) as COMMAND. See the RPC_CALL reference for the signature, synchronous/asynchronous semantics and result-code table.