How to display inline values from Jira REST api into confluence
Asked by Tom:

Hello everyone,

My goal is to display the value of a Jira REST query result into a confluence page, inline with the text. I am aware of the /jira macro but that does not cut it as it renders ugly gray boxes that break the line.

Here an example of what I'd like to see in confluence and how in my head i'd like to get it done:

In my confluence page I've the following sentence as normal text:

* "The value of the field is **value** " - I'd like for the world **value**to be dynamically generated based upon the value of a Jira issue field.

The way i dream for this to work is:

* "the value of the field is /command GET_VALUE from <https://companyName.atlassian.net/rest/api/2/issue/PRJ-1/> id:123456"

Now this would get me the value of the field id: 123456 from the REST api for project PRJ-1 and display it as text in confluence.

What i don't want:

1. Text displayed in tables that messes up the layout,
2. text rendered by the /jira macro that disrupts the layout and doesn't sit in line with my paragraph,

Any direction is appreciated since i am new here and i am losing my mind around macros and other articulated concepts. Just some simple JSON parsing, HTLM, CSS or running some JS/Python somewhere would relieve my stress.

Thanks


Answers:
author: David Bakkers
body: The out-of-the box Jira macro for Confluence returns values in tabular format. You're going to need something like ScriptRunner do to the REST based lookup behind the scenes and return some raw text that you can put on the page.

Alternatively, third party tools like the Stiltsoft Table Filters can manipulate the heck out of the data returned by the Jira macro and format it in all sorts of way on the Confluence page.

comments: author: Tom
body: Hello,

I appreciate you taking the time to respond. Table filters seems to be doing just tables (as the name suggests) which is not very useful, unless you want to display data...in a table.

I've inquired Script Runner support, although from their description while it is evident you can query the Jira Api, it is unclear how much you can manipulate and display on confluence.


author: David Bakkers
body: Yes, the output from the Stiltsoft Table filter will still be a table, but if you render the table with no borders, cell padding or colours, nobody will know it's there, all they'll see is the text. The table becomes an invisible container for the text, so it's the simplest solution. Still, in HTML, tables aren't truly inline with text

If you absolutely need the output in that table as text, inline in the page body, you might have to do some browser side page content manipulation with something like JQuery to 'unwrap' the content from the table and put it back in the same place.

The last resort would be to use ScriptRunner to get the value you want, but you'd have to write your own Confluence macro to take that value, put it inside the text, then render it on the page... but then you face a similar issue; macros get treated as separate objects on the page and can't just be inserted inline in any text, anywhere.


Tags: cloud

confluence-cloud

inline

json

page

rest-api

script