Hello,
I'm trying to download all attachments from confluence page using the following python code. the downloaded files are 0 kb
I changed the authorization to be using username and password
the result is the same
what could be wrong? how can I fix it?
import os, os.path
from atlassian import Confluence
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
path = r'<path for downloaded files>'
page = '<Space URL>'
confluence = Confluence(url= page, verify_ssl = False, token = "<Peronal Token>")
attachments_container = confluence.get_attachments_from_content(page_id=<page id>, start=0, limit=500)
attachments = attachments_container['results']
for attachment in attachments:
fname = attachment['title']
download_link = confluence.url + attachment['_links']['download']
r = requests.get(download_link, headers={"Authorization": "<Peronal Token>"} , verify = False)
if r.status_code == 200:
print('Downloading ' + fname + ' File!')
file = open(os.path.join(path, fname), 'wb')
file.write(r.content)
else:
print(r.status_code)
print('not downloaded')
files in the confluence

downloaded files

MyPassword = getpass.getpass()
confluence = Confluence(url= page, verify_ssl = False, username='<username>', password=MyPassword)
. . .
r = requests.get(download_link, auth=(confluence.username, confluence.password), verify = False)