Automating Confluence Pages

91 Views Asked by At

I want to write pages in Confluence using the API and the lib atlassian.

This code below works:

from atlassian import Confluence

confluence = Confluence(
    url='https://CONFLU-URL/',
    username='USERNAME',
    password='KEY',
    cloud=True)

parent_page_id = confluence.get_page_id(space='GDZ', title='PLAYBOOKS')
page_title = 'T1110'

page_body = '<p>Content</p>'

confluence.create_page(
     space='GDZ',
     title=page_title,
     body=page_body,
     parent_id=parent_page_id,
     type='page',
     representation='storage',
     editor='v2',
     full_width=False
     )['id']

page_id = confluence.get_page_id(space='GDZ', title=page_title)
print(f'Pagina criada com sucesso. ID: {page_id}')

But I cant make a table or use any markdown, like:

from atlassian import Confluence

parent_page_id = confluence.get_page_id(space='GDZ', title='PLAYBOOKS')
page_title = 'T1110'

page_body = '<p>Content</p>'

confluence.create_page(
     space='GDZ',
     title=page_title,
     body=page_body,
     parent_id=parent_page_id,
     type='page',
     representation='storage',
     editor='v2',
     full_width=False
     )['id']

page_id = confluence.get_page_id(space='GDZ', title=page_title)

table_markup = """
|Header 1|Header 2|Header 3|
|------|------|-----|
|Row 1, Col 1|Row 1, Col 2|Row 1, Col 3|
|Row 2, Col 1|Row 2, Col 2|Row 2, Col 3|

# teste

## teste2
"""

confluence.append_page(
    page_id=page_id,
    title=page_title,
    append_body= table_markup,
    type='page',
    minor_edit=False,
    representation='storage'
)

print(f'Página criada com sucesso. ID: {page_id}')

In the past, I have created a Python tool that automates the creation of playbooks based on Mitre ATT&CK, but using Word, and now I need to use Confluence to do the same.

I tried: write confluence pages using markdown I expected: confluence understand markdown and format the content but: confluence doesnt format # test as a title for example

0

There are 0 best solutions below