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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to fetch rich-text using Java API?

ptc-5351325
1-Newbie

How to fetch rich-text using Java API?

Hi all,

I hope this is a simple question to answe!

When I process a WorkItem that I obtained from running an "im viewissue" command, I'm given the options to pull primitive data types such as String, Boolean etc.

I'm trying to get some of the HTML formatting that is available within the Integrity Client, including bold font and tables. Is there a method for doing this using the Java API?

Many thanks,

Rich

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Rich,

Calling the im viewissue command with the --showRichContent option in the CLI will pull the raw HTML in the appropriate fields.

To use this in the API, you would use something like the below code:

Command aCommand = new Command(Command.IM, "viewissue");

Response aResponse;

WorkItem aWI;

String fieldValue;

aCommand.addOption(new Option("showRichContent"));

aCommand.addOption(new Option("fields","field1,field2,field3,...fieldN"));

aCommand.addSelection("<item ID>");

try{

aResponse = cmdRunner.execute(aCommand);

/*cmdRunner is coming from a global function that handles all the try/catch and null checks for doing

IntegrationPointFactory

.getInstance()

.createIntegrationPoint(host, port, apiMajorVersion, apiMinorVersion)

.createSession(user, password)

.createCmdRunner();

*/

for (WorkItemIterator itr = aResponse.getWorkItems(); itr.hasNext();) {

aWI = itr.next();

//handle your workitem

fieldValue = aWI.getField("field1").getString();

}

} catch (APIException e){

//handle exception

}

View solution in original post

2 REPLIES 2

Hi Rich,

Calling the im viewissue command with the --showRichContent option in the CLI will pull the raw HTML in the appropriate fields.

To use this in the API, you would use something like the below code:

Command aCommand = new Command(Command.IM, "viewissue");

Response aResponse;

WorkItem aWI;

String fieldValue;

aCommand.addOption(new Option("showRichContent"));

aCommand.addOption(new Option("fields","field1,field2,field3,...fieldN"));

aCommand.addSelection("<item ID>");

try{

aResponse = cmdRunner.execute(aCommand);

/*cmdRunner is coming from a global function that handles all the try/catch and null checks for doing

IntegrationPointFactory

.getInstance()

.createIntegrationPoint(host, port, apiMajorVersion, apiMinorVersion)

.createSession(user, password)

.createCmdRunner();

*/

for (WorkItemIterator itr = aResponse.getWorkItems(); itr.hasNext();) {

aWI = itr.next();

//handle your workitem

fieldValue = aWI.getField("field1").getString();

}

} catch (APIException e){

//handle exception

}

Thanks for the comprehensive answer, this is exactly what I was looking for!

Many thanks,

Rich

Top Tags