Couldn't download Confluence page attachments with OAuth 2.0 (3LO) app

Hello,

I am making the following request to retrieve the Content of the page.

https://api.atlassian.com/ex/confluence/{cloud_id}/wiki/api/v2/pages/{id}?body-format=export_view

From the response, I was able to extract the Attachment URLs which looks like the following -

[
        {
          "url": "https://{domain}/wiki/download/attachments/{page_id}/{file_name}?api=v2",
          "type": "original_url"
        }
      ]

To download the attachments I tried calling the following APIs but all of the endpoints returns 401 Unauthorized

Request #1:

GET https://{domain}/wiki/download/attachments/{page_id}/{file_name}?api=v2

Request #2:

GET https://api.atlassian.com/ex/confluence/{cloud_id}/wiki/download/attachments/{page_id}/{file_name}?api=v2

Request #3:

GET https://api.atlassian.com/ex/confluence/{cloud_id}/wiki/download/attachments/{page_id}/{file_name}?api=v2&download=true

I have looked into this community post about download attachments with 3LO app but still couldn’t figure out a way to download these attachments from the confluence page.

@ibuchanan Could you please assist here?

Welcome to the Atlassian developer community @Uday,

I’m not sure how you’ve obtained those URLs, but there is a dedicated group of API resources for attachments.

1 Like

@ibuchanan I am still not able to figure out even after going to this specific page for attachments that you said

from their we are able to get the relative path for download from _links parameter field

but after that when i form the whole url like

https://api.atlassian.com/ex/confluence/7be77db7-eb3e-4b1a-a8d3-11caca18ea18//download/attachments/2588673/Page.pdf?version=1&modificationDate=1724825357358&cacheVersion=1&api=v2

I am getting this

HTTP error occurred: 401 Client Error: Unauthorized for url: https://api.atlassian.com/ex/confluence/7be77db7-eb3e-4b1a-a8d3-11caca18ea18//download/attachments/2588673/Page.pdf?version=1&modificationDate=1724825357358&cacheVersion=1&api=v2 - {“code”:401,“message”:“Unauthorized; scope does not match”}

and I am damn sure i have given all the necessary scopes permisiion and also my access token is correct since it is able to correctly hit other api endpoints

please provide a solution it’s urgent