Import Gliffy diagram to Confluence page via Rest API
Asked by Victor:

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.


Answers:
author: Davin Studer
body: 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
```

comments: author: Victor
body: 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.


author: Davin Studer
body: This is where you can see the storage format of a page. The other option would be to add in the [Confluence Source Editor](https://marketplace.atlassian.com/apps/1210722/confluence-source-editor?hosting=server&tab=overview) 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](https://community.atlassian.com/t5/image/serverpage/image-id/148113i89D9DAACE87614DF/image-size/large?v=v2&px=999 "image.png")


author: Victor
body: 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.


author: Davin Studer
body: 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.


author: Nachiketh Subramanya N
body: [@Davin Studer](/t5/user/viewprofilepage/user-id/781467)

Is there an API Call we can use to mass download Gliffy diagrams from Spaces instead of Pages?

Please let me know, would be really helpful to know if that's available.

Thanks,

Nachiketh.


author: Samie Kaufman - Your Gal at Gliffy
body: Hi [@Nachiketh Subramanya N](/t5/user/viewprofilepage/user-id/5074337) !

I'm not sure if this is possible. I'd like to invite you to email our support team at support@gliffy.com. They may be able to provide some detail. :)


Tags: confluence-server

gliffy

server