-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Request.json() and request.text() return None #2922
Comments
You cannot fetch response's body after exiting from |
Thanks for the advice!
returns the following:
The first 2 print(await response.json()) and print(await response.text()) should work. From the documentation (https://docs.aiohttp.org/en/stable/client_quickstart.html#json-response-content) it seems the json() method should raise an exception when it fails decoding. However, no exception is raised at all, and there's clearly json at the fetched URL. |
Sorry, your code doesn't fit attached output. |
Finally, I found the problem when running the code on windows instead of Ubuntu. On my windows machine, it ran as I expected. The problem: I was still running python 3.5.2 and aiohttp version 2.3.10 on my Ubuntu machine. My bad, I should have checked the version number beforehand:S |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Long story short
I cannot seem to get the text or json response from a response object.
Expected behaviour
I would be able to extract the json via response.json()
Actual behaviour
response.json() gives a None type
response.text() doesn't give anything either
Steps to reproduce
Run this:
In a browser "https://kominherstel.nl/wp-json/wp/V2/pages/" will load.
Your environment
aiohttp==2.3.10
OS: Ubuntu 16.04 LTS
The text was updated successfully, but these errors were encountered: