How to get Rich Text value from JIRA issue

Suman Jha March 12, 2018

I am writing a Plugin for JIRA to another PLM tool, with the help of REST API, I can get the name and other thing, but trying to fetch Description field for any time of Issue. Due to Rich Text rendering I am not able to convert exact Description, please help me to do the same.

 

Example : Actual description looks like below. Like Images table color font etc...

JIRA.jpeg

 

JIRA.jpeg

 

*Scenario:* To validate the columns present in the Related PR table.
*Pre-Requisite:*
# CO should be present in the system.

*Steps:*
# Login as iPLMUser and key in password as lamDEV123.
# Click on MyLamRC present in the Left Hand side Pane !My LamRC.JPG|thumbnail!
# Click on the hyperlink of the CO under the Name Column
# Click on the CO number in the Left Hand Side Panel . !CO Name.JPG|thumbnail!
# Verify if there is a tab named as "Related PR" .It should have a button "Add PR"
*Expected Outcome:*
Related PR Tab should get displayed .Also a button "Add PR" should get displayed. !Related PR and Add PR.JPG|thumbnail!
# Click on Add PR button .Click on Submit Button.The PR should get displayed !Connect Problem Report.JPG|thumbnail! !Results.JPG|thumbnail!
# Click on the check box present beside any PR and do a Drag and Drop on the Drop zone and verify if the PR is getting added to the CO
# It should get added . !PR.JPG|thumbnail!
# Verify if,Following Columns are getting displayed in the "Related PR" tab and columns value are editable.
* Title
* Problem Description
* Number (name)
* Status
* Created
* Submitted
* Originator
* Primary Product Affected
* Priority
* Need Date
* Deviation/Waiver Required
* Reason
* Suggested Solution
* Solution Owner
* Technical Owner
* Planned Completion Date
* Actual Completion Date
* Cause Code
*Expected Outcome:*
Mentioned columns should be present in the "Related PR" tab . !PR.JPG|thumbnail!

 

 

 

2 answers

0 votes
Suman Jha April 12, 2018

Any help would be great Helpful.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 12, 2018

We can't really help you more than what you've seen above.  You know how to request the data, you can see the responses, you now need to work out how to process it into something you need.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 12, 2018

The formatting of the text in the field is done by the renderer which converts data into html formatted output.  The REST API does no rendering, it just hands you the data in the field.

If you want to render it, your code is going to need to parse the wiki markup in the field into a format your target system can understand (which is unlikely to be the same as what you see on a Jira screen anyway)

Suman Jha March 12, 2018

Thanks for your answer, I am bit new to this world. So you mean, I have to use wiki markup to render the same? Do you have any documents how to use wiki markup?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 12, 2018

No, I mean that if you want to see this data in a different format, your code is going to need to understand markup so it can convert it into something your other system can use.

Suman Jha March 12, 2018

I just want to know if Atlassian REST API provide some option to convert wiki markup to HTML. I just need to transfer to HTML format.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 12, 2018

Yes, try adding ?expand=renderedFields

You might not get what you expect or want from it though.

Like # people like this
Suman Jha March 14, 2018

Thanks Nick for your help, I am totally new. Do you have any sample code, how to get wiki markup values in HTML and vice versa. This would be really great help. I am stuck here.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2018

Have you tried adding the expand thing to the REST call you are currently making?

ARVIND KUMAR March 15, 2018

We are you firing this url to get all the issues from Jira :
http://localhost:8999/rest/api/2/search?jql=project=JIRA1

This gives us response, we parse the response and create java objects in our side accordingly.

If description for the issues contains bold,itatic,table etc. then we are getting something like this :


*Bold data* _Italic data_ +Underline data+ {color:#ff0000}Text Color{color} -Strike data- \r\n\r\n[google|http://google.com/]\r\n * *Bulleted List 1*\r\n * Bulleted List 2\r\n\r\n # {color:#f6c342}Numbered List 1{color}\r\n # {color:#f6c342}Numbered List 2{color}\r\n\r\n||Column 1||Column 2||Column3||Column 4||\r\n|A|B|C|D|\r\n| | | | |\r\n\r\n \r\n\r\n  !image-2018-03-07-21-07-28-683.png!\r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n 

 

We would like to convert the above description to something like this :

<p><strong>Bold data</strong></p><p><em>Italic data</em></p><p><s>Strike data</s></p><p><a href="http://google.com" target="_blank">http://google.com</a></p>
<ol>
<li>Numbered list 1</li>
<li>Numbered list 2</li>
</ol>
<ul>
<li>Bulleted list 1</li>
<li>Bulleted list 2</li>
</ul>
<p><span style="color:#FF0000;">Text Color</span></p>
<table border="1" cellpadding="1" cellspacing="1" style="width: 500px;">
<tbody>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
<td>Column 4</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
</tbody>
</table>

 

1) Do we need to write our own converter? I don't think it's good way to solve the problem.

2) Do we need to use something else other then http://localhost:8999/rest/api/2/search?jql=project=JIRA1

Like Guy Vago likes this

Suggest an answer

Log in or Sign up to answer