Skip to content

The SoftLayer_Ticket::addAttachedFile method fails when tried to attach images #506

@MiguelHigorre

Description

@MiguelHigorre

The SoftLayer_Ticket::addAttachedFile method fails when tried to attach images, the following message is raised
SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Ticket): No valid authentication headers found.

Requirements:
Python 2.6 or 2.7
SoftLayer API python client (3.3.1)

It seems to be a problem related to Python 2 since using Python 3 or higher the SoftLayer_Ticket::addAttachedFile method works.

The problem is reproduced with the following code


import SoftLayer
import pprint

apiUsername = 'set-me'
api_key = 'set-me'

apiUsername = 'set-me'
api_key = 'set-me'
ticket_id = set-me
client = SoftLayer.Client(username= apiUsername,api_key=api_key)

f = open('/path/to/image.png', 'rb')
filecontents = f.read()
attachedFile = { 'data': filecontents, 'filename': 'image.png'}
result = client['Ticket'].addAttachedFile(attachedFile, id=ticket_id)
pprint.pprint(result)


Here is the traceback for the Python issue.

Traceback (most recent call last):
File "addAttachedFile.py", line 24, in
result = client['Ticket'].addAttachedFile(attachedFile, id=13410275)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 351, in call_handler
return self(name, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 319, in call
return self.client.call(self.name, name, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 184, in call
return transports.make_xml_rpc_api_call(request)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/transports.py", line 137, in make_xml_rpc_api_call
ex.faultCode, ex.faultString)
SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Ticket): No valid authentication headers found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions