-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON example does not work in Python3 due to encoding differences #9
Comments
On line 34 of On the service-side, the recipe is built from
Are you attempting to modify the image? Perhaps you're rebuilding the recipe from something other than On the client-side, as long as you (1) send valid JSON and as long as (2) |
I was referring to what happens on the clientside, specifically this example code in the README:
This code doesn't work in Python 3 because json.dumps won't dump base64 encoded data to a JSON object. I couldn't figure out how to read the contents of the file and getting it into a JSON object in such a way that the docker container accepted it in Python 3 and just ended up doing it in Python 2.7 instead. |
Could you try this please ?
|
As i had the same issue, this worked for me with python3:
This Link helped: Stackoverflow |
Thank you @sharoonthomas . That helped me alot |
In Python3 encoding to base64 is done with base64.b64encode which creates a bytes object. Json.dumps only takes a string, so the example produces an error.
Attempting to read the file as utf-8 doesn't produce an error, but the resulting PDF is garbled because I assume wkhtmltopdf is expecting a base64 encoded HTML string? Also giving it the --encoding utf-8 option still produces a garbled PDF.
Basically I can't figure out how to get the JSON API working in Python3.
The text was updated successfully, but these errors were encountered: