Reputation: 1
I am trying to access an API using the ETL tool Alteryx, but receive the error:
TypeError: __init__() got an unexpected keyword argument 'encoding'
I am able to run the code in Python 2.7.16 just fine, but the version within Alteryx is 3.6.0. I had to change the JSONRPC file where xmlrpclib was to xmlrpc.client. I then got No module named 'httplib'
. I had to change httplib to http.client. Next, I got the error Cannot import name 'HTTP'
. I saw the line that had from httplib import HTTP, HTTPConnection
and I removed HTTP
. Lastly, I used a web 2to3 python converter for the jsonrpc
file, and added in the line from urllib.parse import (splittype, splithost)
in the jsonrpc
package. I am now to the final two lines, but running into the encoding argument error.
I have tried to install msgpack
, remove the encoding arguments in __init__.py
, and change cls = encoding in __init__.py
for json in CurrentDirectory\Lib\json.
import pprint
from jsonrpclib import jsonrpc
from datetime import datetime
Transaction_Code = datetime.now().strftime('%Y%m%d%H%M%S')
givex = jsonrpc.ServerProxy("host:port")
response = givex.dc_1026('en', Transaction_Code, 'ID', 'password', 'reportname','','')
pprint.pprint(response)
I expect the JSON output for the data, but I receive the following Traceback:
Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Alteryx\bin\Miniconda3\PythonTool_venv\lib\site-packages\jsonrpclib\jsonrpc.py", line 289, in call return self.send(self.__name, args) File "C:\Program Files\Alteryx\bin\Miniconda3\PythonTool_venv\lib\site-packages\jsonrpclib\jsonrpc.py", line 237, in _request rpcid=rpcid, version=self.__version) File "C:\Program Files\Alteryx\bin\Miniconda3\PythonTool_venv\lib\site-packages\jsonrpclib\jsonrpc.py", line 532, in dumps return jdumps(request, encoding=encoding) File "C:\Program Files\Alteryx\bin\Miniconda3\PythonTool_venv\lib\site-packages\jsonrpclib\jsonrpc.py", line 98, in jdumps return json.dumps(obj, encoding=encoding) File "C:\Program Files\Alteryx\bin\Miniconda3\lib\json__init.py", line 238, in dumps """ TypeError: init() got an unexpected keyword argument 'encoding'
Upvotes: 0
Views: 3759
Reputation: 1
With the help from @rickdenhaan I had to use jsonrpclib-pelix instead of jsonrpclib in Python 3.6
Upvotes: 0