Skip to main content
17-Peridot
September 27, 2021
Solved

URLTemplateAction could generate JSON

  • September 27, 2021
  • 1 reply
  • 3403 views

Hi all

When you run a report from a URL using URLTemplateAction you have the option of getting the results in CSV, XML, or HTML formats:

https://support.ptc.com/help/wnc/r12.0.2.0/en/#page/Windchill_Help_Center%2FWCCG_BusLogicCust_ReportGeneration_CustDetails.html%23

But it is 2021, how about the JSON format? Yes I know I could write some XSLT and do this myself.. It looks as if I will need to parse the XML.

Thanks

Rick

Best answer by rhart

Hi @rleir ,

Another option is to run the query builder report using REST, there’s two ways. The report can be Invoked from an IE task or a Generate-Report’ webject action can be invoked directly from REST, both return a JSON or XML object containing the results and you can pass parameter to the query using ‘INPUT’ params from REST. You also have some extras like running two or more reports and getting both results in the same output.

 

http://support.ptc.com/help/windchill/wc111_hc/whc_en/index.html#page/Windchill_Help_Center%2FWC_WebjectLib_GenerateReport_PARAMETERS27.html%23

 

1 reply

14-Alexandrite
September 27, 2021

I've thought this too - it would be a nice addition to the output types.  Depends on what your end goal is and where the users are going to interact with the data.  But if you want JSON you're going to have to use the REST APIs as far as I know.  If I use Query Builder I now am using CSV output and I read this direct into PowerBI. I used to use XML but the CSV is way cleaner, faster, and less error prone.  XML always has some issues with data types changing on enumerations and also with invalid hex characters.  

rleir17-PeridotAuthor
17-Peridot
September 27, 2021

Aaron

Agreed, CSV or TSV is quick and simple. But we have field values containing line breaks, and that problem gets messy.

Yes, the REST API's...   I have done some work with them but could not access all the tables that QB could see. It seemed that development would be quicker if I run a report. Next I will see if WC provides a usable Excel format via excel2000WebQuery.xsl or excel97WebQuery.xsl.

Thanks -- Rick

rhart16-PearlAnswer
16-Pearl
September 27, 2021

Hi @rleir ,

Another option is to run the query builder report using REST, there’s two ways. The report can be Invoked from an IE task or a Generate-Report’ webject action can be invoked directly from REST, both return a JSON or XML object containing the results and you can pass parameter to the query using ‘INPUT’ params from REST. You also have some extras like running two or more reports and getting both results in the same output.

 

http://support.ptc.com/help/windchill/wc111_hc/whc_en/index.html#page/Windchill_Help_Center%2FWC_WebjectLib_GenerateReport_PARAMETERS27.html%23