Reputation: 43
Getting a JSON error on from my code, whats being done wrong here?
import requests
import json
url = "https://tv-v2.api-fetch.website/movies/%7Bpage%7D"
header = {'Content-Type': 'application/json; charset=utf-8'}
response = requests.get(url,headers=header)
madting = json.dumps(response.json())
madness = json.loads(madting)
print(madness)
error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Upvotes: 0
Views: 129
Reputation: 474141
If you inspect the response, you are gonna see <Response 503>
.
The reason is that %7Bpage%7D
part of the URL that does not look right. URL with a numeric value in that place works: https://tv-v2.api-fetch.website/movies/1
- a list of dictionaries with the movie data is printed out on the console.
My best guess is that you've incorrectly string-formatted the actual page
value - may be missing an f
prefix for the f-string?
Upvotes: 1