Issue calling API with Micropython

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

If I use VScode and the 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/”, line 33, in json
ValueError: syntax error in JSON

Here is my script:
import urequests
import json

response = urequests.get(“”)
print(“Data obtained!”)

Can anyone explain why this syntax error is occurring or if my server.js script is causing this error?

can you show what the response body is? then we can look at it and figure out why it’s invalid JSON


<class 'dict'>
    "type": "Dragon",
    "hp": 8,
    "attack": 12,
    "defense": 16

This was done from requests in VScode. When i try to use urequests in micropython on the Raspberry Pi Pico I get the syntax error message. I have the Badger 2040W - it has a preinstalled file that collects weather api data with urequests - that seems to work ok. It’s only when I use the glitch link that I can’t get it to collect the json.

are the 200 and <class 'dict'> part of the response? or are they other logs? the stuff that follows from { to } looks fine

edit: I tried loading the url from my browser and the JSON looks fine from there too.

can you get a copy of the exact request urequests sends? maybe it’s missing a User-Agent header or something. that would get you a 403 (?) error from Glitch. oh yeah, try adding code to check that the response is 200 OK