Download attachment from Confluence page

I am trying to download the file attachments of a Confluence page, using 3LO and rest api v2.

What I’ve tried:

  1. I have all the permissions/scopes needed.
  2. I get the list of the attachments of a page from:
    api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/pages/{pageID}/attachments
  3. From endpoint (2), I get the downloadLink as described here:
    https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-attachment/#api-attachments-get
  4. 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:

  1. api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/pages/{pageID}/attachments/{downloadLink}
  2. api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/pages/{pageID}/{downloadLink}
  3. api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/{downloadLink}
  4. api.atlassian.com/ex/confluence/{cloudID}/wiki/{downloadLink}
  5. 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:

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

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