Skip to main content
1-Visitor
January 15, 2014
Solved

How to fetch rich-text using Java API?

  • January 15, 2014
  • 1 reply
  • 2438 views

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

Best answer by matt_giltaji

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

}

1 reply

1-Visitor
January 17, 2014

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

}

1-Visitor
January 17, 2014

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

Many thanks,

Rich