Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to import ready diagram to Confluence page using API only?

I have some process when I programmatically generate diagrams and then I need to paste these diagrams to the Confluence page. I suppose to use API only.

I realized how I can insert a diagram on page, but before I need to have it in plugin search.

So, my question about importing - how I can execute using API of Confluence  the same action as import diagrams from diagram editor:

 - add macro to the page, then click 'Edit' to launch the diagram editor.

- From there you go File -> Import.

- The XML you are importing needs to be a diagram.

1 answer

1 accepted

1 vote
Answer accepted

Hi Daria,

If you already have the diagram file, you just need to upload it to a page or blog post. You can use the rest endpoint for that. Attachment's content type needs to be "application/vnd.jgraph.mxfile" so search can pick it up.



It works, thank you.

My example of code on Python:

url = CONFLUENCE_BASE_URL+'/rest/api/content/'+CONTENT_ID
headers = {"X-Atlassian-Token": "nocheck"}
files = {'file': ('diagram.drawio', open('tmp/diagram.drawio', 'rb'), 'application/vnd.jgraph.mxfile')}'/child/attachment', data=data, auth=('user', 'password'), files=files, headers=headers)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

145 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you