urequests syntax error - Raspberry Pi Pico - Badger 2040W #13709
Unanswered
red-daruma
asked this question in
Libraries & Drivers
Replies: 1 comment
-
The response is returning something that isn't JSON (look at My guess is that you're missing a request header that the server needs, e.g. commonly one of Btw, please see Welcome (Please read before posting) for how to format code in discussions posts. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I’m a newbie to all things coding but thought I would try to create an API through Glitch.
I’ve made the basic form of the API - the project name is: tulip-peat-rowboat (access to api is through /api/monster)
If I use VScode and the python requests library I can pull the json data and create a basic monster.
But when I try to get the data to display using micropython and the urequests library I’m getting the following:
Data obtained!
<Response object at 2001b850>
Traceback (most recent call last):
File “”, line 7, in
File “requests/init.py”, line 33, in json
ValueError: syntax error in JSON
Here is my script:
import urequests
import json
response = urequests.get(“https://tulip-peat-rowboat.glitch.me/api/monster 1”)
print(“Data obtained!”)
print(response)
print(response.json())
Can anyone explain why this syntax error is occurring. If i run one of the example scripts that comes with the Badger 2040W that connects to a weather api the json comes out fine.
I get the following through python requests library:
200
<class 'dict'>
{
"type": "Dragon",
"hp": 8,
"attack": 12,
"defense": 16
}
Beta Was this translation helpful? Give feedback.
All reactions