Jul-05-2022, 02:16 AM
I was working with an API: Returns Json array of Tags
When I try
Any help is appreciated. Thanks.
r = requests.get('https://cataas.com/api/tags') if r.status_code == 200: with open(f'{log_Dir}Cat tags.json', 'w') as file: json.dump(r.content, file)This code returns an error:
Error:raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable
I think it is because the data is retrieved in Bytes??When I try
print(type(r.content))
within the function:Output:<class 'bytes'>
How is this possible, since when I visit the above url, I get a string of an array?Any help is appreciated. Thanks.