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

How to make JIRA ticket visible in Confluence with REST API

Orlando_Jurcone March 15, 2019

Hi,

 

I am creating a new Confluence Page in Python using REST API.

The code looks something like this:

 

url = "https://newconfluence.company.org/rest/api/content"
data = {"type":"page", "ancestors":[{"type":"display", "id":2687111}], "title":"Test", "space":{"key":"WE"},"body":{"storage":{"value":source,"representation":
"storage"}}}
headers = {'Content-Type':'application/json'}

r = requests.post(url, data=json.dumps(data), headers=headers, auth=('user', 'password'))

 

where "source" is a file with the html code.

 

I tried different html code in source file to make Jira tickets look nicer in the new created Confluence page, but some things are not loading properly.

 

Below are some examples of html code for Jira ticket:

Example 1 (in this case I get only the text inside <p> in Confluence, but the Jira link doesn't appear)

<p>
https://newjira.company.org/browse/WEL-17779
</p>

 

Example 2 (for this case, I took with copy+paste the html code generated by Confluence when the same thing is created manually. Again the link to Jira is not visible in Confluence)

 

<div class="content-wrapper">
<p>
<span class="jira-issue conf-macro output-block" data-client-id="SINGLE_9e98b881-494d-3ae4-bac8-efcab923ca19_28770699_8a79831767658b27016813d1d7ed0006" data-hasbody="false" data-jira-key= " WEL-17779" data-macro-name="jira">
<a href="https://newjira.company.org/browse/WEL-17779" class="jira-issue-key"><span class="aui-icon aui-icon-wait issue-placeholder"> </span>WEL-17779</a>
-
<span class="summary">Getting issue details...</span>
<span class="aui-lozenge aui-lozenge-subtle aui-lozenge-default issue-placeholder">STATUS</span>
</span>
</p>
</div>

 

This is how Jira ticket looks in Confluence for Example 2(link with Jira is not done)

Jira.PNG

when it should look like this:

image.png

Is there a way to make the link between Jira and Confluence using REST API?

Can someone please help me with this?

 

Thanks in advance!

1 answer

1 accepted

2 votes
Answer accepted
Orlando_Jurcone March 19, 2019

I found the answer. So I need to have "Jira Issue/Filter" Macro imported.

Below is the html code used:

<ac:structured-macro ac:name='jira'>
<ac:parameter ac:name='columns'>key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name='key'>WEL-17779</ac:parameter> </ac:structured-macro>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events