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

Embed JIRA ISSUES Macro to Rest API Content

https://confluence.atlassian.com/confcloud/jira-issues-macro-724765217.html

 

Hi guys, i can embed issues via the JIRA issues filter.

But how can i do this programatically, via the rest api.

 

Let's say, i want to create a new page in confluence via 

POST https://carousell.atlassian.net/wiki/rest/api/content/

 

What is the exact thing to do for the JIRA ISSUES FILTER?

3 answers

Hi Sathish,

Confluence pages are basically some sort of html containing special snippets of Confluence Markup. If you'd like to add a JIRA macro you could use the following snippet of Confluence Markup in your POST body:

<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name="maximumIssues">20</ac:parameter>
<ac:parameter ac:name="jqlQuery">JQL_QUERY</ac:parameter>
<ac:parameter ac:name="serverId">JIRA_SERVER_ID</ac:parameter>
</ac:structured-macro>

If you're wondering where you can find the Server Id, you can use the following Knowledge Base article: Finding your Server ID.

Hope this helps.

Best,

Maarten

Btw: I've tested this on JIRA Server. Could work a little different on Cloud but is worth trying. Please do let us know if it worked!

I managed to do it on cloud eventually using,

<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'>ABC-123</ac:parameter> </ac:structured-macro>

 

However, is there any confluence page by jira that lists all macro? It's dissapointing to see that 'ac:structured-macro', 'ac:name='jira' are no where to be found in confluence wiki :(

Hi Sathish,

Looks very similar to the syntax on Server (except for the serverId). :-)

There's a list with all macro's but that does not contain all technical values: Macros. On the other hand, the list of macros also differs depending on the installed addons.

If you'd like to see a list of all macros in use on your Confluence you can go to: https://<YOURSITE>.atlassian.net/wiki/admin/pluginusage.action

That page will show a list of all macros (their technical name) and the number of times they have been used.

Best,

Maarten

Thanks for the reply! That page helps alot! It took me so long to find the macro name which is jira in this case as it wasn't documented anywhere. But this page is definitely helpful! Thanks!

Any way to make this list static and not dynamic with a refresh button?

Is there documentation somewhere on how to do this through python?

Hello Josie,

 

I just did this with Python.

Here is the code

#open source.txt file

fSource = open("source.txt", "r")
source = fSource.read()

#Rest API

url = "https://newconfluence.company.org/rest/api/content"

data = {"type":"page", "ancestors":[{"type":"page", "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'))

 

#in the source.txt I have the following code

 <p>
<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>
</p>

#WEL-17779 - is the Jira ticket key name

#That's it. I hope it helps

I tried this method, didn't work out for me. However, I have figured out another way for this simple post request.

Other steps remain the same, making source files with the same syntax.

from atlassian import Confluence, Jira

fSource = open("source.txt", "r")
SourceFileToImport = fSource.read()

status = confluence.create_page(
space='space-name',
title="titlename",
body=SourceFileToImport)

It works like a charm for me!

Hi,

Is there any documentation is there for JAVA?

Thanks

Naveen

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

383 views 23 8
Join discussion

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