UTF-8 decode error when downloading files
You may encounter the following message when attempting to download files from the API:
'utf-8' codec can't decode byte
Unfortunately, the requested file may not be compatible with UTF-8 encoding, and it may consequently cause the Python client to throw the decode error above.
The
Python client attempts to decode any payload to string formats using UTF-8
within the request call of rest.py
. This is done in line 220 in
swagger_client/rest.py
, utilizing the following Python 3
code:
if six.PY3:
r.data = r.data.decode('utf8')
To
solve this, you need to modify the rest.py
file of the Swagger client in
a way that is appropriate to your project’s needs. Alternatively, it is also
possible to download files via HTTP or HTTPS, using a different library.
DocumentClassificationSample/execute.py.