Python 3.6 urllib TypeError: can’t concat bytes to str

The data argument is expected to be a bytes-like object. you need to do the following:

urllib.request.urlopen({api_url}, data=bytes(json.dumps(headers), encoding="utf-8"))

Leave a Comment