json.loads Error: ‘utf-8’ codec can’t decode byte 0x83 in position 0: invalid start byte

All of a sudden I started getting a decoding error for JSON response from this URL:


UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 0: invalid start byte
Unicode error hint
The string that could not be encoded/decoded was: �� ��

I can not find any character’s that are not UTF-8 compliant.

Python 3.8:

import json
import requests

url = "https://stockx.com/api//browse?productCategory=sneakers&sort=featured&order=DESC&_search=CQ4227-030&dataType=product"

headers = {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,'
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'en-US,en;q=0.9',
    'Connection': 'keep-alive',
    'Host': 'stockx.com',
    'TE': 'Trailers',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
                  'Chrome/89.0.4389.128 Safari/537.36'

my_response = requests.get(url, headers=headers)

if my_response.ok:
    j_data = json.loads(my_response.content)


Note, my_response.encoding returns ‘utf-8’


From my testing, it seems like the ‘Accept-Encoding’ header is forcing it into unreadable bytes. If you want the request in plaintext just remove this header and print my_response.text, otherwise, just learn how to deal with the encodings you requested