SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#1 19-06-2024 19:22:37

Registered: 20-11-2018
Posts: 148

Config XLayer (Config and XSLT) to send JSON with spaces in elements

In order to send JSON to an API that looks as follows (NOTICE the spaced in the element names):

    "myFirstArrayElement": [
            "json": {
                "Problem Ticket Number": "INC00012345",
                "Reference Person ID": "cr:000123"

You need to use both XLayer Configuration and XSLT

The XSLT must look as follows:

<xsl:stylesheet version="1.0" xmlns:xsl="">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
    <xsl:template match="/">
<root class="object">
    <myFirstArrayElement class="array">
        <blank class="object">
            <json type="string"><xsl:value-of select="//*[local-name() = 'mBuildBody']"></xsl:value-of></json>

then in your XLayer configuration you need a datadefinition with the following:

<sxi:DataDefinition name="callRPABotAPI">
        <sxi:Field name="na_3">
                <sxi:Field staticValue="yes">{&quot;Problem Ticket Number&quot;: &quot;</sxi:Field>
                <sxi:Field staticValue="yes">&quot;,&quot;Reference Person ID&quot;: &quot;</sxi:Field>
                <sxi:Field staticValue="yes">&quot;}</sxi:Field>

where the fields mRef_num contains the value "INC00012345" and mPersid contains the value "cr:000123"

Refer to Correct JSON format from XML Stylesheet for RESTConnector for additional information on how to convert XML to JSON


Board footer

Powered by FluxBB