Hello community,
There was a post from a while back asking about how to get attachments of a confluence page via REST API. https://community.atlassian.com/t5/Answers-Developer-Questions/confluence-pages-get-attached-files-via-REST-API/qaq-p/529873
The reason I'm asking is I have over 1000 attachments on a page and its growing every day. The problem is I don't want to see the old attachments anymore in my REST call because the data has already been handled from them and I just want to look at newer attachments only with the call. I was wondering if this could be taken a step further somehow and get attachments for a page within a specified time range or greater than a certain start time (this can based off either its modified or creation date)? I didn't see any attributes showing dates in the returned JSON but maybe someone knows a way to check for this :/
Thanks
You could use the CQL search REST API like this. Replace {Your Server} with your Confluence server and {Containing Page ID} with the page id that the attachments are attached to. This will get attachments to that page that are created or updated in the last 14 days.
https://{Your Server}/rest/api/search?cql=type%20%3D%20attachment%20and%20container%20%3D%20{Containing Page ID}%20and%20(created%20%3E%3D%20startOfDay(%22-14d%22)%20or%20lastmodified%20%3E%3D%20startOfDay(%22-14d%22))
This is the CQL not URL encoded ...
type = attachment and container = {Containing Page ID} and (created >= startOfDay("-14d") or lastmodified >= startOfDay("-14d"))
I was not even aware that Confluence had its own query language. This was exactly what I needed. Thank you!
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.