Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi!
I'm trying to post a device serialnumber to remote URL (not Thingworx) with PostXML-function and get a response with some device details (see below).
By using var xmlDocument = Resources["ContentLoaderFunctions"].PostText(params) I get the following response nicely as string:
<?xml version="1.0" encoding="UTF-8"?>
<Devices>
<Total>0</Total>
<Device>
<DeviceData>
<SerialNumber>A66M38</SerialNumber>
<DeviceType>10</DeviceType>
</DeviceData>
<ItemData Quantity="1" Version="">
<Description1 Lang="EN">Development engine</Description1>
</ItemData>
</Device>
</Devices>
But if I try to do anything with PostXML (e.g. xmlDocument to Infotable) it seems that I do not get any XML data to Thingworx. I wonder, whether PostXML can be used in a case like this to get result as XML object? Am I missing something in PostXML usage?
Quite a simple result so I could even use some sort of light-weight parser inside service? Any hints?
Br,
Pasi
Should work, if this is what you get back when you do PostText, then your PostXML should be able to get this back as an XML object.
So if you had var myXML = Resources.["ContentLoaderFunctions"].PostXML
Then you should be able to get information from myXML.Devices.Total
PostText delivers the content nicely. PostXML just like you said, but myXML.Devices.Total is empty. Any idea where to start hunting the reason for this behavior? Could it be that content-type is a problem for Thingworx? Using Postman I see that the content-type for response is text/xml; charset=utf-8.
Do you have the UTF-8 option configured in the Java opts?
You mean in the tomcat/catalina startup?
Hi Pasi,
Don't lose time with PostXML, use PostText and then if you want you can try to parse to XML the content you receive with new XML(postTextResult); or alike.
Just my recommendation,
Carles.
Thanks. I will check the encoding issue first and if it does not help, continue with building the case with posttext.