Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Inhalt
maxLevel5

Releases

VersionDateNotesCompatibility
1.0.020.01.2023First published versionfrom Nuclos 4.2022.25.1

Overview

This Nuclet supports the use of external REST services in rule code.

Version 1.0

Description of version 1.0.0

TopicDescription
REST-ProtokollThe BO System > REST-Protokoll logs all requests generated by the Nuclet
Use in rulesThe class RESTUtils provides several methods for this

Use in the rule programming of version 1.0.0

Class RESTUtils
static RESTContext execute(RESTContext restContext)
Performs a request with the properties specified in restContext .
Example GLS shipping order (JSON)

RESTContext restContext = new RESTContext();
restContext.setAddress(credentials.getAddress());
restContext.setRequest(getRequest(credentials, bo, referenceLabel));
restContext.setReference("GLS: Post Shipment for " + referenceProtokoll);

restContext.setEncoding(RESTContext.ENCODING_UTF_8);
restContext.setContentType(RESTContext.FORMAT_JSON);
restContext.setAcceptEncoding("gzip,deflate");
restContext.setAcceptLanguage("de");
restContext.setAccept(RESTContext.FORMAT_JSON);
restContext.setAuthorization(RESTContext.Authorization.Basic);
restContext.setUser(credentials.getUser());
restContext.setPassword(credentials.getPassword());

context.log("Starte Übermittlung des Lieferscheins anStarting transmission of the delivery note to GLS: " + restContext.getUrlWithParameters());
RESTUtils.execute(restContext);
RESTShipmentResponseGLS response = null;
if (restContext.isError()) {
context.log("Error while transmitting the GLS Shipment Response: " + restContext.getErrorMessage());
} else {
try {
response = objectMapper.readValue(restContext.getResponse(), RESTShipmentResponseGLS.class);
// ...
    } catch (JsonProcessingException e) {
throw new BusinessException("Error while evaluating the GLS Shipment Response: " + e.getMessage());
}
}

Example VAT ID check (inline)


 

RESTContext result = new RESTContext();

result.setContentType(RESTContext.FORMAT_APPLICATION_X_WWW_FORM_URLENCODED);
result.setEncoding(RESTContext.ENCODING_UTF_8);
result.setTest(Boolean.FALSE);
result.setAddress(pruefungsObjekt.getUrl());
result.addParameter(Parameter.UST_ID_1, pruefungsObjekt.getValue(Parameter.UST_ID_1));
result.addParameter(Parameter.UST_ID_2, pruefungsObjekt.getValue(Parameter.UST_ID_2));
result.addParameter(Parameter.FIRMENNAME, pruefungsObjekt.getValue(Parameter.FIRMENNAME));
result.addParameter(Parameter.ORT, pruefungsObjekt.getValue(Parameter.ORT));
result.addParameter(Parameter.PLZ, pruefungsObjekt.getValue(Parameter.PLZ));
result.addParameter(Parameter.STRASSE, pruefungsObjekt.getValue(Parameter.STRASSE));
result.setReference("VAT ID check for subject " + pruefungsObjekt.getPruefling());

RESTUtils.execute(restContext);

Integration of version 1.0.0

The integration after a successful Nuclet import (see Nuclet import) is to be carried out as follows.

StepDescriptionScreenshot
1Run the job once Initialisiere Nuclet REST-Client-Utils (under Administration > Job control)

...