<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://www.xlayer.co.za/forum/extern.php?action=feed&amp;tid=151&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[SXI Forum / Config XLayer (Config and XSLT) to send JSON with spaces in elements]]></title>
		<link>https://www.xlayer.co.za/forum/viewtopic.php?id=151</link>
		<description><![CDATA[The most recent posts in Config XLayer (Config and XSLT) to send JSON with spaces in elements.]]></description>
		<lastBuildDate>Wed, 19 Jun 2024 17:22:37 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Config XLayer (Config and XSLT) to send JSON with spaces in elements]]></title>
			<link>https://www.xlayer.co.za/forum/viewtopic.php?pid=232#p232</link>
			<description><![CDATA[<p>In order to send JSON to an API that looks as follows (<em>NOTICE</em> the spaced in the element names):</p><div class="codebox"><pre><code>{
    &quot;myFirstArrayElement&quot;: [
        {
            &quot;json&quot;: {
                &quot;Problem Ticket Number&quot;: &quot;INC00012345&quot;,
                &quot;Reference Person ID&quot;: &quot;cr:000123&quot;
           }
        }
    ]
}</code></pre></div><p>You need to use both XLayer Configuration and XSLT</p><p>The XSLT must look as follows:</p><div class="codebox"><pre><code>&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
    &lt;xsl:output method=&quot;xml&quot; indent=&quot;yes&quot; omit-xml-declaration=&quot;yes&quot;/&gt;
    &lt;xsl:template match=&quot;/&quot;&gt;
&lt;root class=&quot;object&quot;&gt;
    &lt;myFirstArrayElement class=&quot;array&quot;&gt;
        &lt;blank class=&quot;object&quot;&gt;
            &lt;json type=&quot;string&quot;&gt;&lt;xsl:value-of select=&quot;//*[local-name() = &#039;mBuildBody&#039;]&quot;&gt;&lt;/xsl:value-of&gt;&lt;/json&gt;
        &lt;/blank&gt;
    &lt;/workItems&gt;
&lt;/root&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</code></pre></div><p>then in your XLayer configuration you need a datadefinition with the following:</p><div class="codebox"><pre><code>&lt;sxi:DataDefinition name=&quot;callRPABotAPI&quot;&gt;
      &lt;sxi:Fields&gt;
...
        &lt;sxi:Field name=&quot;na_3&quot;&gt;
          &lt;sxi:Rules&gt;
            &lt;sxi:Concatenation&gt;
              &lt;sxi:Delimiter&gt;&lt;/sxi:Delimiter&gt;
              &lt;sxi:Fields&gt;
                &lt;sxi:Field staticValue=&quot;yes&quot;&gt;{&amp;quot;Problem Ticket Number&amp;quot;: &amp;quot;&lt;/sxi:Field&gt;
                &lt;sxi:Field&gt;mRef_num&lt;/sxi:Field&gt;
                &lt;sxi:Field staticValue=&quot;yes&quot;&gt;&amp;quot;,&amp;quot;Reference Person ID&amp;quot;: &amp;quot;&lt;/sxi:Field&gt;
                &lt;sxi:Field&gt;mPersid&lt;/sxi:Field&gt;
                &lt;sxi:Field staticValue=&quot;yes&quot;&gt;&amp;quot;}&lt;/sxi:Field&gt;
              &lt;/sxi:Fields&gt;
            &lt;/sxi:Concatenation&gt;
          &lt;/sxi:Rules&gt;
          &lt;sxi:OutputField&gt;mBuildBody&lt;/sxi:OutputField&gt;
        &lt;/sxi:Field&gt;
...
      &lt;/sxi:Fields&gt;
    &lt;/sxi:DataDefinition&gt;</code></pre></div><p>where the fields mRef_num contains the value &quot;INC00012345&quot; and mPersid contains the value &quot;cr:000123&quot;</p><p>Refer to <a href="https://www.xlayer.co.za/forum/viewtopic.php?id=138" rel="nofollow">Correct JSON format from XML Stylesheet for RESTConnector</a> for additional information on how to convert XML to JSON</p>]]></description>
			<author><![CDATA[dummy@example.com (SeanR)]]></author>
			<pubDate>Wed, 19 Jun 2024 17:22:37 +0000</pubDate>
			<guid>https://www.xlayer.co.za/forum/viewtopic.php?pid=232#p232</guid>
		</item>
	</channel>
</rss>
