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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • 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 draw.io diagram to Confluence page using API only?

I have some process when I programmatically generate draw.io 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 draw.io 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 draw.io 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 draw.io 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.

 

Boris.

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')}
requests.post(url+'/child/attachment', data=data, auth=('user', 'password'), files=files, headers=headers)

Suggest an answer

Log in or Sign up to answer
TAGS
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