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.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Boris Jockov _draw_io_ ( & @Daria Antsupova )!
If I update the drawio diagram via the API, will the preview (rendered image on the confluence page) that the drawio macro results in also be updated (or be updated when the page is rendered, either way so that the new diagram is used and shown) ?
BR! /marcus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@mawiThe PNG preview is generated on diagram save, it's a client-side operation. The diagram shown on the page view is the diagram itself, the viewer is JavaScript that loads and displays the diagram.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.