How to deal with Integration that does not return lisible reply

Certified Senior Developer

Hi,

I'm calling an external Integration which works fine, but when I try to set the "Convert JSON to Appian value" option, the Integration returns the error below.

1/ How would you do to deal with that error ? do I have no other choice to deal with the raw response ?
(it is an old API, and we can not ask any update)

error-result-guidance
The response body could not be converted to an Appian value The jsonText parameter was not valid JSON. Received: <...



2/ In raw mode, the API response is like this (please see below). It contains XML not really practical, and there are a lot characters to escape.
How would you do to extract informations in a clean way (or to convert it in Json) ?

We've tried functions such a "tojson" but without satisfactory results. Of course using "extract" function works, but I'm looking for the best way to do it please.

<?xml version='1.0' encoding='UTF-8'?> 
	<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='http://ldap.xxxxxx.fr/LdapWS/client/'>
	<SOAP-ENV:Body>
		<ns1:listeUsersResponse>
			<response>
				<demandeRecue>true</demandeRecue>
				<xml><?xml version='1.0' encoding='UTF-8'?>
					<data>
						<listeUsers><titre><![CDATA[M.]]></titre><nom><![CDATA[DUPONT]]></nom><prenom><![CDATA[Nicolas]]></prenom><color><![CDATA[Red]]></color><size><![CDATA[10]]></size></listeUsers>
						<listeUsers><titre><![CDATA[M.]]></titre><nom><![CDATA[DURAND]]></nom><prenom><![CDATA[Pauline]]></prenom><color><![CDATA[blue]]></color><size><![CDATA[15]]></size></listeUsers>
					</data>
				</xml>
			</response>
		</ns1:listeUsersResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 

Regards

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You are receiving an XML but trying to use it as a json

  • 0
    Certified Senior Developer
    in reply to David J (NTT DATA)

    Yes of course, as I wrote, it is some XML data, but not very practical...
    How would you parse it for an Appian using ?

    Would you convert it first to Json ? (and then to a CDT)
    or directly from XML to CDT ?

    The goal is to to be able to using it with Appian objects...

  • +1
    Certified Lead Developer
    in reply to cedric01

    The problem is that the xml is not correct. The end tag of the first list listeUsers elements is incorrect.

    IN your xml is written as listeUser, and it should be listeUsers...

    Once changed, works fine

    a!localVariables(

    local!xml: "<?xml version='1.0' encoding='UTF-8'?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV='schemas.xmlsoap.org/.../' xmlns:ns1='ldap.xxxxxx.fr/.../'>
    <SOAP-ENV:Body>
    <ns1:listeUsersResponse>
    <response>
    <demandeRecue>true</demandeRecue>
    <xml><?xml version='1.0' encoding='UTF-8'?>
    <data>
    <listeUsers><titre><![CDATA[M.]]></titre><nom><![CDATA[DUPONT]]></nom><prenom><![CDATA[Nicolas]]></prenom><color><![CDATA[Red]]></color><size><![CDATA[10]]></size></listeUsers>
    <listeUsers><titre><![CDATA[M.]]></titre><nom><![CDATA[DURAND]]></nom><prenom><![CDATA[Pauline]]></prenom><color><![CDATA[blue]]></color><size><![CDATA[15]]></size></listeUsers>
    </data>
    </xml>
    </response>
    </ns1:listeUsersResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>",


    (xmltojson(local!xml))

    )

  • 0
    Certified Senior Developer
    in reply to David J (NTT DATA)

    Sorry, I made a typing error in this post (I've corrected it above addind the missing "s").

    My unexpected issue is that the forum code snippet has formatted my XML flow correctly, but I did not want this, to be able to explain you my problem ;-)

    My real flow is this one below.

    Could you tell me how to convert all these tags : &lt;data&gt; to this <data> please ?
    if I use striphtml() function, then it breaks the XML, and I can not make the Json conversion afterwards.

    ----
    <?xml version='1.0' encoding='UTF-8'?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV='schemas.xmlsoap.org/.../' xmlns:ns1='ldap.xxxxxx.fr/.../'>
    <SOAP-ENV:Body>
    <ns1:listeUsersResponse>
    <response>
    <demandeRecue>true</demandeRecue>
    <xml>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
    &lt;data&gt;
    &lt;listeUsers&gt;&lt;titre&gt;&lt;![CDATA[M.]]&gt;&lt;/titre&gt;&lt;nom&gt;&lt;![CDATA[DUPONT]]&gt;&lt;/nom&gt;&lt;prenom&gt;&lt;![CDATA[Nicolas]]&gt;&lt;/prenom&gt;&lt;color&gt;&lt;![CDATA[Red]]&gt;&lt;/color&gt;&lt;size&gt;&lt;![CDATA[10]]&gt;&lt;/size&gt;&lt;/listeUsers&gt;
    &lt;listeUsers&gt;&lt;titre&gt;&lt;![CDATA[M.]]&gt;&lt;/titre&gt;&lt;nom&gt;&lt;![CDATA[DURAND]]&gt;&lt;/nom&gt;&lt;prenom&gt;&lt;![CDATA[Pauline]]&gt;&lt;/prenom&gt;&lt;color&gt;&lt;![CDATA[blue]]&gt;&lt;/color&gt;&lt;size&gt;&lt;![CDATA[15]]&gt;&lt;/size&gt;&lt;/listeUsers&gt;
    &lt;/data&gt;
    </xml>
    </response>
    </ns1:listeUsersResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    ----


    and thank you for the "xmltojson" function, I understand I do not have such a function because it comes from a plugin.

  • 0
    Certified Lead Developer
    in reply to cedric01

    Use this

    a!localVariables(

    local!xml: "<?xml version='1.0' encoding='UTF-8'?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV='schemas.xmlsoap.org/.../' xmlns:ns1='ldap.xxxxxx.fr/.../'>
    <SOAP-ENV:Body>
    <ns1:listeUsersResponse>
    <response>
    <demandeRecue>true</demandeRecue>
    <xml>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
    &lt;data&gt;
    &lt;listeUsers&gt;&lt;titre&gt;&lt;![CDATA[M.]]&gt;&lt;/titre&gt;&lt;nom&gt;&lt;![CDATA[DUPONT]]&gt;&lt;/nom&gt;&lt;prenom&gt;&lt;![CDATA[Nicolas]]&gt;&lt;/prenom&gt;&lt;color&gt;&lt;![CDATA[Red]]&gt;&lt;/color&gt;&lt;size&gt;&lt;![CDATA[10]]&gt;&lt;/size&gt;&lt;/listeUsers&gt;
    &lt;listeUsers&gt;&lt;titre&gt;&lt;![CDATA[M.]]&gt;&lt;/titre&gt;&lt;nom&gt;&lt;![CDATA[DURAND]]&gt;&lt;/nom&gt;&lt;prenom&gt;&lt;![CDATA[Pauline]]&gt;&lt;/prenom&gt;&lt;color&gt;&lt;![CDATA[blue]]&gt;&lt;/color&gt;&lt;size&gt;&lt;![CDATA[15]]&gt;&lt;/size&gt;&lt;/listeUsers&gt;
    &lt;/data&gt;
    </xml>
    </response>
    </ns1:listeUsersResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>",


    substitute(substitute(local!xml, "&lt;", "<"), "&gt;", ">")

    )

  • 0
    Certified Senior Developer
    in reply to David J (NTT DATA)

    yes, it is what I have already did :-)  (like with extract or substitute)
    but I was looking for a real Appian function that converts all automatically... but I suppose it does not exist...

  • 0
    Certified Lead Developer
    in reply to cedric01

    No , there is no function that makes that conversion automatically..... you can use substitute, extract, or regular expressions...

  • 0
    Certified Senior Developer
    in reply to David J (NTT DATA)

    ok, thanks a lot for your help.
    I will install the "xmltojson" plugin, this is the function I was missing...

Reply Children
No Data