I am trying to upload a csv file using requests.post function in python. I convert the csv file to string so that i can use JSON to upload the data on the url. But when I try to post the data I get an error saying:
raise JSONDecodeError("Expecting value", s, err.value) from None
JSONDecodeError: Expecting value
Can someone please tell me what I can do to solve this issue?
data_csv = data.to_string()
type(data_csv)
results = {}
for xm in [True, False]:
results[xm] = requests.post(url_base + 'estimator',
headers = api_header, proxies=proxyDict,
json = {'data_csv': {'csv': data_csv},
'clearing_currency': 'EUR',
'is_cross_margined': xm}).json()
print('Example of margin output:')
print(json.dumps(results[False]['portfolio_margin'], indent=4, sort_keys=True))