z4r / python-rtkit

Python Api for Request Tracker's REST interface
http://z4r.github.com/python-rtkit/
Other
68 stars 44 forks source link

Comment API with attachment #57

Open rashed2014 opened 7 years ago

rashed2014 commented 7 years ago

Hello, it seems there are some issues with the comment API with Attachment. I am able to send .txt file but nothing else. Not even .JPG. I keep getting [ERROR] 'ascii' codec can't decode byte 0xef in position 407: ordinal not in range(128). Here is my code:

file_open = file(full_filename) content = {

                "content": {
                    'id': _ticket,
                    'Action': 'comment',
                    'Text': comment_text,
                    'Attachment': uploaded_filename
                },
                'attachment_1': file_open
            }

resource = RTResource(uri, username, password, CookieAuthenticator)

response = resource.post(path='ticket/' + _ticket + '/comment', payload=content, )

Any suggestion?