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.

0 answers

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