Forums

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

Python API display content on Confluence

alk
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!
October 23, 2023

Hello :)

How can attached files/content be displayed on a confluence page?

Using Atlassian Python API confluence.attach_content/confluence.attach file does not display the attachment.

For images the code below can be used as the append body to display an image

f"""<ac:image>
<ri:attachment ri:filename="{file_name}" />
</ac:image>"""

How can this be achieved if the content/file is html?

Thanks,

Alan

 

1 answer

0 votes
Gonchik Tsymzhitov
Community Champion
October 24, 2023

Hi! 

that that file already attached on the page?

alk
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!
October 25, 2023

yes this is the working code for displaying a image of a plot with update capability

def plot_to_confluence(plot_to_post, name:str, page_id:str, page_title:str, update=False):
file_name = f"{name}.png"
plot_to_post.figure.savefig(file_name)
confluence.attach_file(file_name, name=file_name, content_type=None, page_id=page_id, title=None, space=None, comment=None)
if not update:
html = f"""<ac:image>
<ri:attachment ri:filename="{file_name}" />
</ac:image><br/>"""
confluence.append_page(page_id, page_title, html, parent_id=None, type='page', representation='storage', minor_edit=False)

plot_to_confluence(plot, 'plot_name', page_id, page_title)

 I'd like to be able to post html (e.g. a table) with update capability. Perhaps `<ac:image>` can be replaced with something else to do this?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events