Hello,
please forgive me if this is a badly formulated post or a stupid question. I am fairly new to creating/debugging codes.
I have a problem when I try to update the existing Confluence page via Python code.
The code is really simple, just to test the rivers :
from atlassian import Confluence
conf_site = 'https://confluence.x-x-x.com'
conf_user = 'x-x-x'
conf_pass = 'x-x-x'
page_title = 'x-x-x'
page_space = 'x-x-x'
# connect to Confluence
conf = Confluence(url=conf_site, username=conf_user, password=conf_pass)
# resolve page ID
page_id = conf.get_page_id(page_space, page_title)
# new page content
page_content = '<p>This is the new updated text of the page</p>'
# update page with new content
conf.update_page(page_id, page_title, page_content)
The problem is, this plain and simple code gives me an error:
Traceback (most recent call last):
File "C:/Users/x-x-x/test2 dpc.py", line 14, in <module>
page_id = conf.get_page_id(page_space, page_title)
File "C:\Program Files (x86)\Python310-32\lib\site-packages\atlassian\confluence.py", line 219, in get_page_id
return (self.get_page_by_title(space, title, type=type) or {}).get("id")
File "C:\Program Files (x86)\Python310-32\lib\site-packages\atlassian\confluence.py", line 314, in get_page_by_title
return response.get("results")[0]
AttributeError: 'str' object has no attribute 'get'
Therefore, I suspect the problem is with conf.get_page_id(page_space, page_title). I am quite certain page_title = 'x-x-x' and page_space = 'x-x-x' are correct, so is the https://confluence.x-x-x.com.
When I tried to print what is returned by conf.get_page_id, it returns 2500 lines long HTML. Should it be this way? What am I doing wrong?