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

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

Import Gliffy diagram to Confluence page via Rest API

I have diagram file in Gliffy format (filename.gliffy). It can be made using export or another tool.

But how can I import it on Confluence page using Rest API? I tried to do it via file attachment, but diagram didn't appear on the page (but it is quite understandable).

I need exactly automated process (Rest API), not manual import.

Thank you

Victor.

1 answer

1 accepted

Do you have the Gliffy app for confluence as well? Without that Confluence will not be able to render the Gliffy attachment correctly. If indeed you do here's what I would do. Manually create a Gliffy diagram and save the page. Then look at the storage format that is created for this. (Page menu -> Storage Format). This will tell you the structure that you need to add into your page content to point to the Gliffy file you uploaded to the page. Then you would use this REST endpoint to update your page content to add in the storage format the structure that points to the attached Gliffy file.

URL: http(s)://{confluence base url}/rest/api/content/{pageid}
Method: PUT

 

Thank you, Davin. You solution helps.

I attach two files, .png and .gliffy. It is imporant to set correct comments on files - GLIFFY IMAGE and GLIFFY DIAGRAM. Gliffy  diagram file must be without extension.

I couldn't find Page menu -> Storage Format, but I made GET request 

/rest/api/content/354568600?expand=body.storage

on page with sample gliffy diagram to see page body, it returns macro in body:

<ac:structured-macro ac:name=\"gliffy\" ac:schema-version=\"1\" ac:macro-id=\"4c35e5ac-c7b5-41c0-847f-4e31b6734512\"><ac:parameter ac:name=\"name\">diag111</ac:parameter><ac:parameter ac:name=\"pagePin\">1</ac:parameter><ac:parameter ac:name=\"\" /></ac:structured-macro>

Further I PUT page in Confluence with macro, and all was fine, diagram  draws correctly. I didn't change macro-id, but there was no errors.

Like Davin Studer likes this

This is where you can see the storage format of a page. The other option would be to add in the Confluence Source Editor app. It's a free app made by Atlassian. It gives you the option to edit the page storage format while you are in edit mode.

image.png

Like Victor likes this

Yes, I watched this menu, but no 'Storage format', Export to PDF came right after View Source. May be not all features are installed or problems in access rights.

Yeah, looks like you need to be a space admin to see that menu item. What you did works as well ... using the REST API to view the storage format ... it's just not as convenient.

Suggest an answer

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

🏑 Atlympic Event: Confluence

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

459 views 18 15
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