I’m making a get request to a url to get back a json file. This works fine in postman. Converted the code to python where I get this error:
UnicodeEncodeError: ‘latin-1’ codec can’t encode characters in position 0-5: ordinal not in range(256)
def get_pois():
url = "https://example.com/iv/api/site/2086220822020250/pois?lang=en"
payload = {}
headers = {
'Accept': 'application/json',
'X-Authorization': get_token(),
'Authorization': '••••••'
}
response = requests.request("GET", url, headers=headers, data=payload, verify=False)
print(response.text)
I tried to change lang from en to en_US.utf8
I tried to add ‘Content-Type’: ‘text/html; charset=utf-8’
I tried to encode but the error seems to come with the request so I don’t know where I can encode something.
Probably the problem comes with the return of the body because there are url’s in the returning json.
You need to sign in to view this answers