Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Publish confluence page with Latest jira issue macro

Harmeet Singh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 1, 2025

I am using a python script to publish a confluence page. The content of page is using jira macros. Below is my Sample script:


import requests
import json
import sys
CONFIG = {
"space_key": "YOUR_SPACE", # your test space key
"parent_page_id": "1234567890", # TEST page parent ID
"page_title_template": "{release_version} Release Overview Dashboard",
"release_version": "", # Will be set from command line
"auth_email": "your.email@company.com",
"auth_token": "YOUR_ATLASSIAN_API_TOKEN_HERE"
}
def build_page_body(release_version):
return f"""
<ac:layout>
<ac:layout-section ac:type="single" ac:breakout-mode="default">
<ac:layout-cell>
<h2> Detailed Reporting</h2>
<!-- Product Stats Table -->
<ac:structured-macro ac:name="table" ac:schema-version="1" data-layout="align-start">
<ac:parameter ac:name="width">1051</ac:parameter>
<ac:rich-text-body>
<table data-table-width="1051" data-layout="align-start">
<colgroup>
<col style="width: 171.0px;" />
<col style="width: 880.0px;" />
</colgroup>
<tbody>
<tr>
<th>
<p><strong>Product</strong></p>
</th>
<th>
<p><strong>Detailed Stats</strong></p>
</th>
</tr>
<tr>
<td>
<p>Product</p>
</td>
<td>
<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">System Jira</ac:parameter>
<ac:parameter ac:name="columns">issuetype,key,summary,customfield_11221,customfield_11439,assignee,customfield_11411,status,customfield_11216,customfield_11419,customfield_10858,customfield_11039,customfield_10996,customfield_10997,customfield_11037</ac:parameter>
<ac:parameter ac:name="jqlQuery">project in (PROJ1) and fixVersion = {release_version} and issuetype not in (Task, Sub-task) ORDER BY issuetype DESC</ac:parameter>
<ac:parameter ac:name="maximumIssues">100</ac:parameter>
<ac:parameter ac:name="serverUrl">https://your-company.atlassian.net</ac:parameter>
</ac:structured-macro>
</td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
</ac:layout-cell>
</ac:layout-section>
</ac:layout>
"""

def create_or_update_confluence_page():
headers = {"Content-Type": "application/json"}
page_title = CONFIG["page_title_template"].format(release_version=CONFIG["release_version"])
print(f"🔹 Searching for page: {page_title}")

# Check if page exists
search_url = f"{CONFIG['base_url']}/rest/api/content"
params = {
"title": page_title,
"spaceKey": CONFIG["space_key"],
"expand": "version"
}

try:
search_response = requests.get(
search_url,
headers=headers,
params=params,
auth=(CONFIG["auth_email"], CONFIG["auth_token"]),
verify=False, # SSL verification disabled
timeout=15
)
except Exception as e:
print("❌ Failed to search page:", e)
return

if search_response.status_code != 200:
print("❌ Failed to search page:", search_response.status_code, search_response.text)
return

results = search_response.json().get("results", [])
page_body = build_page_body(CONFIG["release_version"])

if results:
# Page exists → update it
page_id = results[0]["id"]
version = results[0]["version"]["number"] + 1
update_url = f"{CONFIG['base_url']}/rest/api/content/{page_id}"
update_data = {
"id": page_id,
"type": "page",
"title": page_title,
"version": {"number": version},
"body": {"storage": {"value": page_body, "representation": "storage"}}
}
response = requests.put(
update_url,
headers=headers,
data=json.dumps(update_data),
auth=(CONFIG["auth_email"], CONFIG["auth_token"]),
verify=False
)
if response.status_code in [200, 201]:
print(f"✅ Existing page updated successfully! (ID: {page_id})")
else:
print("❌ Failed to update page:", response.status_code, response.text)

else:
# Page does not exist → create new
create_url = f"{CONFIG['base_url']}/rest/api/content/"
create_data = {
"type": "page",
"title": page_title,
"ancestors": [{"id": CONFIG["parent_page_id"]}],
"space": {"key": CONFIG["space_key"]},
"body": {"storage": {"value": page_body, "representation": "storage"}}
}
response = requests.post(
create_url,
headers=headers,
data=json.dumps(create_data),
auth=(CONFIG["auth_email"], CONFIG["auth_token"]),
verify=False
)
if response.status_code in [200, 201]:
page_id = response.json()['id']
print(f"✅ Page created successfully! (ID: {page_id})")
else:
print("❌ Failed to create page:", response.status_code, response.text)

if __name__ == "__main__":
try:
print("🚀 Script started")
if len(sys.argv) < 2:
print("❌ Usage: python script.py <release_version>")
sys.exit(1)

CONFIG["release_version"] = sys.argv[1]
print(f"Release version: {CONFIG['release_version']}")

create_or_update_confluence_page()
except Exception as e:
print("❌ Exception occurred:", e)

The issue is that the macro to show items matching the JQL is always coming in legacy format , I want the latest jira issues macro to be used. Specific part on above script where macro is used :
<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">System Jira</ac:parameter>
<ac:parameter ac:name="columns">issuetype,key,summary,customfield_11221,customfield_11439,assignee,customfield_11411,status,customfield_11216,customfield_11419,customfield_10858,customfield_11039,customfield_10996,customfield_10997,customfield_11037</ac:parameter>
<ac:parameter ac:name="jqlQuery">project in (PROJ1) and fixVersion = {release_version} and issuetype not in (Task, Sub-task) ORDER BY issuetype DESC</ac:parameter>
<ac:parameter ac:name="maximumIssues">100</ac:parameter>
<ac:parameter ac:name="serverUrl">https://your-company.atlassian.net</ac:parameter>
</ac:structured-macro>
How I want macro to be:
< This Is manually edited the confluence page >
Screenshot 2025-09-01 at 1.36.42 PM.png
This is how the above script is publishing the page:
< it is using the legacy JIRA macro>
Screenshot 2025-09-01 at 1.41.39 PM.png
Need help to find the storage format code to publish confluence page with latest jira issues macro.

1 answer

0 votes
marc -Collabello--Phase Locked-
Community Champion
September 4, 2025

On thing you can do is to manually make a page with the format you want, and then check the storage format of the page.

You can then use this storage format as a template for your script. 

Harmeet Singh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 4, 2025

@marc -Collabello--Phase Locked- 

Thanks for responding.

I tried with that as well. Below is the storage format code snippet from the manual page which is working fine - 


<p>Product</p> <td><a href="https://xxxx.atlassian.net/issues/?jql=project%20in%20(Product)%20and%20fixVersion%20%3D%20Release%20and%20issuetype%20not%20in%20(Task%2C%20Sub-task)%20ORDER%20BY%20issuetype%20DESC" data-card-appearance="block" data-datasource="{&quot;id&quot;:&quot;d8b75300-dfda-4519-b6cd-e49abbd50401&quot;,&quot;parameters&quot;:{&quot;cloudId&quot;:&quot;fa86794b-9159-4385-8b5c-d8ef89fb2ca9&quot;,&quot;jql&quot;:&quot;project in (Product) and fixVersion = Release and issuetype not in (Task, Sub-task) ORDER BY issuetype DESC&quot;},&quot;views&quot;:[{&quot;type&quot;:&quot;table&quot;,&quot;properties&quot;:{&quot;columns&quot;:[{&quot;key&quot;:&quot;issuetype&quot;},{&quot;key&quot;:&quot;key&quot;},{&quot;key&quot;:&quot;summary&quot;},{&quot;key&quot;:&quot;status&quot;,&quot;width&quot;:185},{&quot;key&quot;:&quot;customfield_10998,customfield_11027,customfield_11340,customfield_12232&quot;},{&quot;key&quot;:&quot;assignee&quot;,&quot;isWrapped&quot;:true},{&quot;key&quot;:&quot;customfield_10858&quot;},{&quot;key&quot;:&quot;customfield_10996&quot;}]}}]}">https://xxxx.atlassian.net/issues/?jql=project%20in%20(Product)%20and%20fixVersion%20%3D%20Release%20and%20issuetype%20not%20in%20(Task%2C%20Sub-task)%20ORDER%20BY%20issuetype%20DESC</a></td></tr> 


The confluence page is getting published as below. Looks like it is publishing the page in new JIRA macro format( which is required) but it is not using using "List" as appearance. Currently in storage format of Manually Published page it is using data-card-appearance="block", we tried changing it to list/List/LIST as well but it does not publish the confluence page in table/list format. If I manually edit the confluence age published with above storage format code to select the List type, then also it converts this to List/Table format, but the columns mentioned in above storage format code are missing from that List/Column.
Screenshot 2025-09-04 at 5.26.13 PM.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events