Skip to content
Advertisement

Error while updating Confluence page using Python

status = confluence.update_page(
parent_id=None,  
page_id={con_pageid},
title={con_title},
body='Updated Page. You can use <strong>HTML tags</strong>!')

Using this code gives me the following error:

Traceback (most recent call last): File “update2.py”, line 24, in status = confluence.update_page(

File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/atlassian/confluence.py”, line 1513, in update_page if not always_update and body is not None and self.is_page_content_is_already_updated(page_id, body, title):

File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/atlassian/confluence.py”, line 1433, in is_page_content_is_already_updated current_title = confluence_content.get(“title”, None)

AttributeError: ‘str’ object has no attribute ‘get’

Does anyone have an idea on how to update a confluence page using python? I’ve tried various solutions provided even here, but none of them is working for me.

Advertisement

Answer

Finally tweaked a code that works. Providing whole code in case anyone would need it later.

import requests
from atlassian import Confluence

confluence = Confluence(
    url='https://confluence.<your domain>.com',
    token='CyberPunk EdgeRunners')

status = confluence.get_page_by_title(space='ABC', title='testPage')
print(status)

status = confluence.update_page(
    parent_id=<a number sequence>,
    page_id=<a number sequence>,
    title='testpage',
    body='<h1 id="WindowsSignatureSet2.4.131.3-2-HandoffinstructionstoOperations">A</h1>'
) 
print(status)
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement