-
Notifications
You must be signed in to change notification settings - Fork 705
Open
Description
I am trying to download attachments from confluence pages. Because I have been getting 401 errors when calling download_attachments_from_page() (it worked yesterday?) I also included get_attachments_from_content().
def downloadFileFromConfluence(logger, Confluence, confluencePageID, dlFolder):
logger.info("[" + str(datetime.datetime.now()) + "] --- Start of download from Confluence.")
try:
# Download all attachments from the given page
attachments = Confluence.get_attachments_from_content(confluencePageID, start=0, limit=50, expand=None, filename=None, media_type=None)
print(attachments)
Confluence.download_attachments_from_page(confluencePageID, path=dlFolder)
except Exception as e:
print(str(e))
logger.error("[" + str(datetime.datetime.now()) + "] --- An error occured while accessing Confluence!")
logger.error("[" + str(datetime.datetime.now()) + "] " + str(e))
The console output from this piece of code is
{'results': [{'id': 'att67907559', 'type': 'attachment', 'ari': 'ari:cloud:confluence:8babfdf0-f329-48b6-9de1-52a8a936740f:attachment/67907559', 'base64EncodedAri': 'YXJpOmNsb3VkOmNvbmZsdWVuY2U6OGJhYmZkZjAtZjMyOS00OGI2LTlkZTEtNTJhOGE5MzY3NDBmOmF0dGFjaG1lbnQvNjc5MDc1NTk=', 'status': 'current', 'title': 'Amaris Overview 220221.pdf', 'macroRenderedOutput': {}, 'metadata': {'mediaType': 'application/pdf'}, 'extensions': {'mediaType': 'application/pdf', 'fileSize': 1519699, 'comment': '', 'mediaTypeDescription': 'PDF Document', 'fileId': '08f7fe95-ad82-42db-9af9-1413c54d3742', 'collectionName': 'contentId-67895904'}, '_expandable': {'container': '/rest/api/content/67895904', 'restrictions': '/rest/api/content/att67907559/restriction/byOperation', 'history': '/rest/api/content/att67907559/history', 'body': '', 'version': '', 'descendants': '/rest/api/content/att67907559/descendant', 'space': '/rest/api/space/IT', 'childTypes': '', 'schedulePublishInfo': '', 'operations': '', 'schedulePublishDate': '', 'children': '/rest/api/content/att67907559/child', 'ancestors': '', 'draftVersion': ''}, '_links': {'webui': '/pages/viewpageattachments.action?pageId=67895904&preview=%2F67895904%2F67907559%2FAmaris+Overview+220221.pdf', 'self': 'https://<our org>.atlassian.net/wiki/rest/api/content/att67907559', 'download': '/download/attachments/67895904/Amaris%20Overview%20220221.pdf?version=1&modificationDate=1646135898000&cacheVersion=1&api=v2'}}], 'start': 0, 'limit': 50, 'size': 1, '_links': {'base': 'https://<our org>.atlassian.net/wiki', 'context': '/wiki', 'self': 'https://<our org>.atlassian.net/wiki/rest/api/content/67895904/child/attachment'}}
HTTP error occurred while downloading attachments: Unauthorized (401)
Getting the list of the (one) attachment(s) works. But once I want to download them, the call gives me an "Unauthorized (401)". I checked this also via stepping through, just so I am sure that download_attachments_from_page() is throwing that 401.
I MUST be doing something wrong. The user and api token can curl the page without problems on the command line.
Before I re-write the rest calls myself (which I'd rather not), I thought it can't hurt to ask here.
Metadata
Metadata
Assignees
Labels
No labels