Skip to content

request

Calls a remote REST/API endpoint.

actionValues
payloadKey key where the (JSON) response will be stored
request
url absolute or relative URL to the http-endpoint
method HTTP method to be used (POST, PUT, DELETE)
params JSON Object of key/values
timeout default: 60

Since Version 22.0.0 the request action has new several defaults and improvements for easier configuration:

  • You may now emit the params object in the configuration, if you do not have any parameters to send. No dummy parameters are needed.
  • You may now emit the headers object in the configuration in Insight Standalone. The default (for Insight Standalone) is:
{
    "Accept": "application/json",
    "Content-Type": "application/json"
}

With url

{
    "action": "request",
    "actionValues": [
        {
            "payloadKey": "activity"
        }
    ],
    "request": {
        "method": "POST",
        "url": "insight/action/business-suite/activity/get",
        "params": {
            "activityId": "${$context.$record.properties.activityId}"
        }
    },
    "then": {
        "action": "request",
        "request": {
            "method": "POST",
            "url": "https://your-other-api.com/request",
            "params": {
                "result": "${$payload.activity}"
            }
        }
    }
}

With script

  • You may now use a script tag in the request action configuration. Doing so will set the request method to POST as a default, but can still be overriden via the old configuration.
  • You can now break up long request url configurations in the script tag. The request url will be generated from these settings:
{
    "action": "request",
    "script": {
        "backend": "business-suite",
        "name": "my-script"
    }
}

With script and params

  • You can additionally configure the params object in the script object as well:
{
    "action": "request",
    "script": {
        "backend": "business-suite",
        "name": "my-script",
        "params": {
            "id": "${id}",
            "user": "${userData.login}"
        }
    }
}

Difference between Maximo und OpenJet configuration

Maximo / MBO API

{
    "action": "request",
    "request": {
        "method": "POST",
        "url": "rest/mbo/WORKORDER/${WORKORDERID}",
        "params": {
            "WOPRIORITY": "1",
            "DESCRIPTION": "${DESCRIPTION} + ${userData.personid} + ${appParams.standort}"
        },
        "headers": {
            "Content-Type": "application/x-www-form-urlencoded"
        }
    }
}

OpenJet

request calls a remote method.

{
    "label": "Verheiraten",
    "shortLabel": "Verheiraten",
    "action": "request",
    "icon": "icon-man-woman",
    "request": {
        "method": "POST",
        "url": "insight/eam/rpc/insightTest/mitarbeiter",
        "params": {
            "vorgesetzter": "${dstObject.uniqueId}",
            "mitarbeiter": "${srcObject.uniqueId}"
        },
        "headers": {
            "Content-Type": "application/x-www-form-urlencoded"
        }
    }
}

RPCHandler Implementation

import gis.openframe.bol.BusinessObject;

import java.util.Map;

import de.ibfs.insight.rpc.api.RpcContext;
import de.ibfs.insight.rpc.api.RpcHandler;

public class MitarbeiterVerknueppler implements RpcHandler {
    @Override
    public void call(RpcContext context) throws Exception {
        Map<String, String> parameters = context.getParameters();
        String vorgesetzterId = parameters.get("vorgesetzter");
        String mitarbeiterId = parameters.get("mitarbeiter");
        if (vorgesetzterId.equals(mitarbeiterId)) {
            return;
        }
        Person target = PersonFactory.get(vorgesetzterId);
        Person mitarbeiter = PersonFactory.get(mitarbeiterId);

        BusinessObject[] parents = mitarbeiter.getLinkSourceObjects(Person.folgt);
        for (BusinessObject businessObject : parents) {
            ((Person) businessObject).removeFolgt(mitarbeiter);
        }
        target.addFolgt(mitarbeiter);
    }
}

Registration in InitComponent

public void globalInit() {
    try {
        RpcRegistry service = OpenJetServiceRegistry.getService(RpcRegistry.class);
        service.register("insightTest/mitarbeiter", MitarbeiterVerknueppler.class);
    }
    catch (Throwable t) {
        gis.util.Trace.error("RpcRegistry", "Fehler beim Versuch RpcRegistry zu laden", t);
    }
}