I just tried with the Rest API plugin, seems to give the correct result.
Hadd to use CORS proxy, probably because it should be requested from backend??
Thank you very much for this fast and helpful reply!
I didnât try using the call in a workflow but just had a look at the result in the collection definition. I will continue working on this tomorrow, but Iâm sure you found the solution. Thank you again!
Best regards,
Bert
In the beginning, the workflow didnât work as intended. But I eventually found the 2 issues:
The RPC only works using GET, not POST.
The response seemed to be contained in a data string like this:
" UstId_1 ErrorCode 215 UstId_2 Druck nein Erg_PLZ Ort Datum 08.08.2024 PLZ Erg_Ort Uhrzeit 11:48:39 Erg_Name Gueltig_ab Gueltig_bis Strasse Firmenname Erg_Str "
I first tried extracting the ErrorCode using a JS string function but this never worked (result always null).
Actually, the result string is an XML structure like the one from above:
I then asked Gemini once again and it suggested a specific XML script:
function extractErrorCode(xmlString) {
// Create a DOMParser instance
const parser = new DOMParser();
// Parse the XML string into a DOM document
const xmlDoc = parser.parseFromString(xmlString, âtext/xmlâ);
// Get all elements
const params = xmlDoc.getElementsByTagName(âparamâ);
// Iterate over params to find the one with key âErrorCodeâ
for (let i = 0; i < params.length; i++) {
const keyElement = params[i].getElementsByTagName(âstringâ)[0];
if (keyElement.textContent === âErrorCodeâ) {
const valueElement = params[i].getElementsByTagName(âstringâ)[1];
return valueElement.textContent;
}
}
return null; // Handle case where ErrorCode not found
}
const xmlString = context.workflow[â3bdd1ccc-f5c6-457a-8ac7-872566f61929â].result?.[âdataâ]/* your XML string here */;
const errorCode = extractErrorCode(xmlString);
// console.log(errorCode); // Output: 200 >> valid
return(errorCode);
This works perfectly! I now added a workflow True/False split using the returned ErrorCode: 200 = valid (true), other codes: error message