I am using the Python request module and having trouble converting my response.text into a Python dictionary.
def my_function():
url = API_URI["test"]
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(api), headers=headers)
print(r.text)
dict = r.json()
return dict
my_function()
Here is the printed response from r.text
{"subscriptionId":"8530989","profile":{"customerProfileId":"507869879","customerPaymentProfileId":"512588514"},"refId":"12345","messages":{"resultCode":"Ok","message":[{"code":"I00001","text":"Successful."}]}}
And the error
raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
I have tried both json.loads(r.text) and r.json()
I see that the error wants me to decode, but where?