speix
January 7, 2024, 12:13pm
1
I am trying to download the file attachments of a Confluence page, using 3LO and rest api v2.
What I’ve tried:
I have all the permissions/scopes needed.
I get the list of the attachments of a page from:
api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/pages/{pageID}/attachments
From endpoint (2) , I get the downloadLink as described here:
https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-attachment/#api-attachments-get
Then I tried every possible combination of endpoints to get the file, but they all fail with:
code : 401 message : Unauthorized; scope does not match or 404 not found
Endpoints I tried to grab the file:
api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/pages/{pageID}/attachments/{downloadLink}
api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/pages/{pageID}/{downloadLink}
api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/{downloadLink}
api.atlassian.com/ex/confluence/{cloudID}/wiki/{downloadLink}
api.atlassian.com/{downloadLink}
Nothings works!
How can I download the attachment of a page using api v2 with an authenticated app?
2 Likes
I’m no expert but saw your post and do have this working. Take a look at:
Hi,
There are so many questions so far around the topic “How to download attachments content using OAuth2”. What is surprising, no one gave a definite answer about it, either not answering or giving the obscure one.
So I would like to ask Atlassian’s developers once again. Is there any possibility to download attachments content using OAuth2?
So far it was possible using download link e.g “https://{instance_url}/wiki/download/attachments/{id}/{name}”. Right now it is not possible any more. It…
Specifically, I think you need to use the V1 endpoint added specifically for downloading the content using OAuth (no V2 version that I can see):
https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-attachmentid-download-get
Apologies if I’m misinterpreting your question!
Mark
speix
January 10, 2024, 11:46am
3
Thank you @MarkSpooner , yes I’m aware that with v1 it’s possible, that is what I’m currently doing to get the files. I was wondering about v2, and if I was missing something obvious using it.
Thank you.
@speix ,
The V2 API is not a complete replacement for V1. So not everything exists in the V2 API. Please continue to to use the V1 API for attachments.
1 Like