I'm looking to create a custom script to get and display data from a file attached to a document, e.g. a json or csv file.
I know there are macros that display these files, but if I'm looking to do something more, how can I get access to the files attached to a confluence page or workspace.
E.g. lets say there is a data.json file that I want to attach, and I want to write a custom script to process and display that data in an interesting way, how can I get access to that. It is trivial to do if that csv were hosted elsewhere, then I'd make a request for the document itself via the url. But when it is attached to a page, I don't know what that url is, or whether there is some other mechanism.
Hi @dejongnj ,
welcome to the Atlassian community!
You can retrieve attachments within your script through the resta api.
For confluence server : https://docs.atlassian.com/ConfluenceServer/rest/8.0.0-m90/#api/content/{id}/child/attachment-getAttachments
For confluence cloud : https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-get
Hope this helps,
Fabio
Thanks! THis looks to be what I was looking for! Much appreicated.
Any way to do that directly from the browser? (TBH - I've found a hack that may work, but not sure whether it will work consistently).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My suggestion is to use postman ;)
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.