Python API - programmatically saving image


I work for a company that logs usability issues on websites. We are presently using word documents that we save into PDFs. The main problem with the existing export methods (CSV and HTML) is that it does not include attachments.

We want to migrate towards using YouTrack to log issues. That said, we still want to be able to generate document reports with all of the issues from a project.

We figured that we should be able to use the Python Library (

I have been able to use this to grab issue summaries, descriptions, etc. The one thing I cannot do is grab the attachments of issues. I need to be able to save the attachments of images to disk and then use the files to write a document (e.g. docx or PDF).

But I just cannot do this. It seems to be an authentification issue. For example, the following:

# Login

connection = Connection("https://{myrepo}", "email", "pw")

 # Get list of attachments frome one issue

attachments = connection.getAttachments("SMS3-19")

 # Only gets the first one for testing - will need to make a foreach loop

attachment = attachments[0]

filename = attachment['name']

 with open(filename, "w") as f:


Just writes to a file that -- when opened with a Notepad -- is just the YouTrack login page. It seems like I can access the issue, attachments, attachments URL, etc., but the login that the library allows does not allow me to save files to disk.

Does anyone have any guidance on this matter?

1 comment
Official comment

I'm sorry for the delay. Please refer to the answer here:

Please sign in to leave a comment.