Forums

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

Facing some issues while trying to export a enterprice confluence page into doc

Manoj
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!
June 26, 2025

So normally when i go into browser and hit export to docx , its working perfectly fine , im able to download the doc , but programatically i tried doing that with the api and every time i get a sinle page as output ( that is the login page ) . Here is the code i used . 

import requests

CONFLUENCE_BASE_URL = "https://your-domain.atlassian.net/wiki" # Change this
PAGE_ID = "123456" # Change to your page's ID
PAT = "your_confluence_pat" # Your Personal Access Token

url = f"{CONFLUENCE_BASE_URL}/exportword?pageId={PAGE_ID}"
headers = {
"Authorization": f"Bearer {PAT}",
"Accept": "application/msword"
}

response = requests.get(url, headers=headers)
if response.status_code == 200:
with open("confluence_export.doc", "wb") as f:
f.write(response.content)
print("Exported successfully!")
else:
print(f"Failed! Status: {response.status_code}")
print(response.text)

 

Thanks in advance 

2 answers

0 votes
Sumukh Shashidhar
Contributor
June 27, 2025

Hi @Manoj ,

OPTION1: Use the REST API to fetch page content and generate word manually
confluence Cloud REST API lets you fetch page content via:
GET /wiki/rest/Api/content/{id}?expand=body.storage

Then, you can:

  1. Parse the HTML (body.storage.value)
  2. Use a Python library like python-docx or html2docx to convert it into a Word .docx file.

while this isn’t as clean as native export, its programmatic and wors well.

OPTION2: Use browser automation 

if you must replicate the browser (e.g., Selenium with ChromeDriver)

Log in using a real user session
Navigate to the export URL and trigger the download
this method mimics the browser and bypasses the logic page issue your hitting.

0 votes
cjafernandez
Banned
June 26, 2025

Token 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events