Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get data from attachment

dejongnj
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 17, 2022

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.

1 answer

1 vote
Fabio Racobaldo [Catworkx]
Community Champion
November 18, 2022

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

dejongnj
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 21, 2022

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).

Fabio Racobaldo [Catworkx]
Community Champion
November 21, 2022

My suggestion is to use postman ;)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events