Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira REST API - Convert Change Log Table from Pipe Format to HTML

Hello,

I am new to REST API and am having difficulty with formatting table data exported from the REST API change log.  My goal is to convert the exported pipe format back into HTML, or something that could ultimately create a visually pleasing table once I push it back to Jira.

Example string output from change log:

"The system shall control the column thermal environment, with a time to cool of:\r\n  \r\n||Time||Start Temperature||End Temperature||Minimum Environmental Temperature||Maximum Environmental Temperature||Flow Rate||Source||\r\n|≤ 10 minutes|≥ 30°C|≤ 5°C|≤ 20°C|≥ 25°C|0.1-1.0 mL/min|UR-108 STK-96|\r\n|≤ 10 minutes|≥ 60°C|≤ 30°C|≤ 20°C|≥ 25°C|0.1-1.0 mL/min|UR-203 STK-96|\r\n\r\nFor a column with ID ≤ 4.6 mm, length ≥ 50 mm (Target 150 mm), no guard column, no pre-column filter, and with passive pre-heater."

The format for headers is "||" and the data delimiter is "|".  Any suggestions?

1 answer

Can you explain further. What is that the changelog of? An issue in Jira?

Can you provide the REST API call you used to get that response from Jira, as data back from the REST API about an issue's changelog comes back in JSON format, not in any format like you've shown.

To me, that looks like the contents of one of the TEXT FIELDS in Jira that supports markdown, like the description or the comments. In markdown, the pipe symbols are used to create tables.

If you intend to 'push' the text data back into Jira, it will have to go into a text field and it will have to use markdown formatting, so it will need to use that 'pipe' formatting, not HTML.

Hey David, thanks for the fast response.

Yes, this is the changelog of a Jira issue - call is as follows:

https://code.waters.com/jira/rest/api/2/issue/SR-51?expand=changelog

The JSON output of one of the history changes includes this pipe formatting.  A single entry from the changelog output is as follows.  The text being modified is within the Jira description field.

{"id":"2455992","author":{"self":"https://code.waters.com/jira/rest/api/2/user?username=uscsei","name":"uscsei","key":"uscsei","emailAddress":"CS@waters.com","avatarUrls":{"48x48":"https://code.waters.com/jira/secure/useravatar?ownerId=uscsei&avatarId=61905","24x24":"https://code.waters.com/jira/secure/useravatar?size=small&ownerId=uscsei&avatarId=61905","16x16":"https://code.waters.com/jira/secure/useravatar?size=xsmall&ownerId=uscsei&avatarId=61905","32x32":"https://code.waters.com/jira/secure/useravatar?size=medium&ownerId=uscsei&avatarId=61905"},"displayName":"CS [X]","active":false,"timeZone":"America/New_York"},"created":"2020-07-29T16:39:27.000-0400","items":[{"field":"description","fieldtype":"jira","from":null,"fromString":" \"The system shall control the column thermal environment, with a time to cool of:\r\n  \r\n||Time||Start Temperature||End Temperature||Minimum Environmental Temperature||Maximum Environmental Temperature||Flow Rate||Source||\r\n|≤ 10 minutes|≥ 30°C|≤ 5°C|≤ 20°C|≥ 25°C|0.1-1.0 mL/min|UR-108 STK-96|\r\n|≤ 10 minutes|≥ 60°C|≤ 30°C|≤ 20°C|≥ 25°C|0.1-1.0 mL/min|UR-203 STK-96|\r\n\r\nFor a column with ID ≤ 4.6 mm, length ≥ 50 mm (Target 150 mm), no guard column, no pre-column filter, and with passive pre-heater.","to":null,"toString":"The system shall control the column thermal environment, with a time to cool of:\r\n  \r\n||Time||Start Temperature||End Temperature||Minimum Environmental Temperature||Maximum Environmental Temperature||Flow Rate||Source||\r\n|≤ 10 minutes|≥ 30°C|≤ 5°C|≤ 20°C|≥ 25°C|0.1-1.0 mL/min|UR-108 STK-96|\r\n|≤ 10 minutes|≥ 60°C|≤ 30°C|≤ 20°C|≥ 25°C|0.1-1.0 mL/min|UR-203 STK-96|\r\n\r\nFor a column with ID ≤ 4.6 mm, length ≥ 50 mm (Target 150 mm), no guard column, no pre-column filter, and with passive pre-heater."}]}

The intent is to push the "toString" text, which includes the table, to Confluence and display as a nice table.  Not sure if this complicates the problem.

So, it is the content of the description field and that field does contain markdown formatting.

Unfortunately, there is currently no mechanism for the REST API to do any conversion to HTML for you, so you'll have to do it yourself. Search the topic 'convert Jira markdown to HTML' for numerous articles on how you can do it using various methods.

Have you considered a different approach, such as getting the data from the source? IE, the person or system that put it into the description field in the first place. It's likely that data would in a 'cleaner' state for more easy conversion.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you