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?
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
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.
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!
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
Hi,
Is there any documentation is there for JAVA?
Thanks
Naveen
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, JirafSource = 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!
It looks like you're new here. Sign in or register to get started.