Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi,
I created a RESt Services which sends back the XML content. I tested this using IE and Firefox and renders as XML within the browser.
I created a ThingTemplate and implemented a service which invokes this REST service and returns as XML. (My end goal is to parse XML and take the values out and use them in my mashup. I will be using a datashape to accomplish this. I tried that the values were blank and during debuggin I find this issue).
I tested this using my Thing and test service, it is successful. I wanted to see the content I used the URL http://localhost:8080/Thingworx/Things/TestWPAConnection/Services/getSupplierEiccSurveySummary?method=post and displays my XML as text. (meaning it hides all my XML tags and displays only those values). The XML is wrapped around HTML and see the Content type as HTML/TXT.
I am wondering how to render this as XML. Is there any configuration or setting I need to use,
I would appreciate your help.
Thanks in advance.
Varathan
Thanks for your tip. When I return my XML (output of as String from Resources["ContentLoaderFunctions"].GetXML(params);), I get "Unable To Convert From com.sun.org.apache.xerces.internal.dom.DocumentImpl to STRING".
I used to GetText and returning that as String shows what I expect.
I added some debug statment and tried to get them as XML and Text. The following are the outputs.
// result: XML
var xmlPage = Resources["ContentLoaderFunctions"].GetXML(params);
// result: STRING
var txtPage = Resources["ContentLoaderFunctions"].GetText(params);
logger.debug(xmlPage);
logger.debug(txtPage);
xmlPage returns only my top node name.
txtPage returns the entire XML as expected.
If I parse txtPage as XML, I see undefined variable when I assign the values to datashape. In case of XML, it is not going through my for loop as there is no content inside it.
I would appreciate your help.
Thanks,
Varathan
We are also looking for solution where external application needs json as response , where thingworx is returning JSON, XML and Text wrapped up with HTML.
Dear Pai,
Could you please provide any alernative solution to return as JSON. We have tested with Multiple REST clints and results comes back as HTML
ideaally it should be JSON if your return type is JSON..
Thanks,
Prabhas
Got the solution.
Please add a header tag with “Accept” with value application/json
Testbed with POSTMAN..
Will get the JSON Only data back.
Thanks,
Prabhas