The SoftLayer_Ticket::addAttachedFile method fails when tried to attach images #506#507
The SoftLayer_Ticket::addAttachedFile method fails when tried to attach images #506#507gordonjm wants to merge 3 commits into
Conversation
… headers found" problem).
There was a problem hiding this comment.
to tackle too many local variable restriction of landscape .. you could may be direclty compare
if sys.version_info[0] <3
not sure who/why the limit of 15 local variables is/was enforced
|
I eliminated "interpreter_version" in favor of "sys.version_info[0]" to get to the local variables limit. |
|
Are we sure that it works this way with Python 3? From a library standpoint with no knowledge of the server's API endpoints I don't know how it would ever assume that an arbitrary parameter needs to be base64 encoded without using a user specifying the xmlrpc_client.Binary type or making assumptions (which is what this PR is making). Any other endpoint that takes an object that has a "data" key is assumed to be base64, which has the following problems:
To me, it seems like the user should give the base64 argument the base64ed value. This should work today with no code change to the library required and fits more in line with SLDN documentation. When it says it expects a base64 encoded value, you should give it a base64 encoded value. Example: attachedFile = { 'data': base64.b64encode(filecontents), 'filename': 'image.png'}
result = client['Ticket'].addAttachedFile(attachedFile, id=ticket_id)or potentially use a xmlrpc.Binary value: attachedFile = { 'data': xmlrpc.Binary(filecontents), 'filename': 'image.png'}
result = client['Ticket'].addAttachedFile(attachedFile, id=ticket_id)or as a SoftLayer-client type (so that other transports like REST will be able to support this): attachedFile = { 'data': softlayer.Base64(filecontents), 'filename': 'image.png'}
result = client['Ticket'].addAttachedFile(attachedFile, id=ticket_id) |

A proposed fix for the "No authentication headers found" problem in issue #506.