The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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?

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events