0

Unable to attach screenshot to a issue using Jira-Python library on Windows 7 machine. I am using the 'rb' option for opening the ".PNG" file but still getting UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 208: character maps to <undefined> error. Also with just 'r' open file option the file gets uploaded but the size is 0.0 kb. Here is the code snippet:

from client import JIRA
jira_options={'server': JIRA_URL}
jira=JIRA(options=jira_options,basic_auth=(usrname,passwd))
issue_obj = jira.issue([new_issue_id])
fileimgpath = "C:/installers/abc.PNG"
imgfile = open(fileimgpath,"rb")
jira.add_attachment(issue_obj,imgfile,"abc.PNG")

Thanks for you help.

VooDooNOFX
  • 4,674
  • 2
  • 23
  • 22

1 Answers1

1

You had:

jira.add_attachment(issue_obj,imgfile,"abc.PNG")

It appears that you have your parameters the wrong way-around

See comment here: [https://answers.atlassian.com/questions/138053/jira-python-attached-file-filename]

Humm: Just come across another link: [http://jira-python.readthedocs.org/en/latest/_modules/jira/client.html] which has:

def add_attachment(self, issue, attachment, filename=None):

Maybe better to use:

jira.add_attachment(issue_obj, attachment=imgfile, filename="abc.PNG")

user2838502
  • 91
  • 1
  • 4