urlopen inconsistent API return format for no content?

17 views Asked by At

I'm using an api http endpoint service where I retrieve some information from their url:

response = urlopen(url, cafile=certifi.where())
print(response.read().decode("utf-8"))

However, sometimes their service returns nothing and the code above prints either: '' or '[]'

The inconsistent returns caused me issues in my json parsing.

I am wondering if this is expected behavior on the end of urlopen, or if it's a bug from the http endpoint I am using?

0

There are 0 answers