'how do I make a GET request with the content type "application/json" and not text/html

I'm tryin go make an reddit rss feed app for a project to school, this is the part of the code that's giving me trouble. I need the data to be sent to me as json but its being sent as a text/html. I tried changing the content-type parameter on the headers variable be it doesnt work

headers= {**headers, **{'Authorization' : f'bearer{TOKEN}'}, **{'content-type':'application/json'}}
if len(headers) >= 3:
  print(f'Headers found: {headers}\nAuthentication Complete')

else:
  print("No headers found, cannot authenticate")

def posts():
  resq = requests.get('https://oauth.reddit.com/r/python/hot', headers=headers)
  print(headers)
  resq.raise_for_status()
  if resq.status_code!= 204 and resq.headers['content-type'].strip().startswith('application/json'):
      try:
        print(resq.json())
      except ValueError:
        print("Value Error")
  else:
    print(resq.headers['content-type'])
    print(resq.status_code)

The terminal prints out the following

Headers found: {'User-Agent': 'MyAPI/0.0.1', 'Authorization': 'RANDOM VALUES', 'content-type': 'application/json'}
Authentication Complete
{'User-Agent': 'MyAPI/0.0.1', 'Authorization': 'RANDOM VALUES', 'content-type': 'application/json'}
content-type: text/html; charset=UTF-8
Status Code: 200

So my status code is 200 meaning I'm connecting to the server properly and passing all auth but I need the content-type to be application/json not text/html. Any ideas on how i can fix this??



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source