cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

exporting result from CLI command into XML

mkhan-2
1-Visitor

exporting result from CLI command into XML

Good Morning,

I apologize if it is a dumb question as I very new to this .

We have a requirements in which I have to collect data via PTC integrity tool. I am thinking of creating batch file but before I want to run command manually to make sure I am getting desire results.

I get the results by running

im issues --query='query name' <== That will give me result in the CLI window

I am just wondering if I can get the result(s) in XML. and then run the next command which is

im viewissue <id>

and get the result in xml file.

Hope I explained it properly

10 REPLIES 10
tdalon
12-Amethyst
(To:mkhan-2)

Hi

You could use the --xmlapi flag and redirect output to a file.

--xmlapi won't be supported anymore in the future.

Using Java API instead of CLI is recommended.

Kind regards.

Thierry

mkhan-2
1-Visitor
(To:tdalon)

ok Thank you. it worked. In order to process the xml file to get the ID so I can run the Viewstate command. what is the right command to use.

attached is output I just need the value of ID field.

<?

<<Fie

for future use I don't even know where to look for Java API. can you help as well?

Thank you for your help

tketz
12-Amethyst
(To:tdalon)

Hi,

Thierry's answer is correct but its not supported for the future.

For better understanding tell us in which format you need to collect the data.

you can export to excel with:

im exportissues --query=<queryname>

(you can define the exported fields with the option --fields=field,field,....)

For more options yu have to use the java api.

Look at your server webpage or at PTC support website under Reference Documents.

Your code need something like this:

// only example not really runnable:

c = new Command();

c.setApp(Command.IM);

c.setCommandName("exportissues");

c.addOption(new Option("Y"));

c.addOption(new Option("querydefinition", "QUERYNAME"));

c.addOption(new Option("exportHeadings"));

c.addOption(new Option("sortField", "Label"));

c.addOption(new Option("fields", "Label,ID,Summary,State,External"));

// ProcessBuilder needed because of

// "not supported from IntegrityAPI"


pb = new ProcessBuilder(c.toStringArray());

p = pb.start();

p.waitFor();


mkhan-2
1-Visitor
(To:tketz)

Thank you for the response. I want the data in XML if it is possible and as easy as importing it to excel as you mentioned above. Is there any easy way to get it into XML?

tketz
12-Amethyst
(To:mkhan-2)

only from java api or very simple is to use reports for this.

it works perfect from the gui but also from CLI:

you should prefer that solution:

Create the report by using GUI and after that you can easily run the report from CLI:

im runreport "reportname" > name.xml

mkhan-2
1-Visitor
(To:tketz)

Thank you. As I am very new to this apologize for this stupid question. How do I create the report?

tketz
12-Amethyst
(To:mkhan-2)

In "Integrity User Viewset" click on Report - Create Report

then choose a name, the query and select as type "Basic - XML"

mkhan-2
1-Visitor
(To:tketz)

Thank you Tobias,

But here lies the problem, I cant use the GUI as everything I am trying to achieve is done through because I want different project to connect to MKS and get the result set. So is there a command that I can run under the command window to achieve the results?

tketz
12-Amethyst
(To:mkhan-2)

first you have to create an report, its an design-element where you describe in which content in which format you want to export.

You can do that from CLI (syntax is not very easy, here you have to look in CLI Reference Guide for im createreport), but better is to do that from GUI.

You only have to do this once!!!

then you can run the report (to get the content) from CLI by using:

im runreport "reportname"

The MKSAPIVIEWER command-line utility may be your best bet. It's a wrapper for the JAVA API that accepts most (perhaps all in 10.9) IM and SI commands and outputs them as XML.

mksapiview --iplocal --xml im issues --query='query name'

As was previously mentioned, the --xmlapi option will not be supported in the near future. It wasn't correct in many cases anyway. the MKSAPIVIEWER should have a longer life and doesn't require any additional coding.

Announcements


Top Tags