I wrote an application in python to basically post some expenses to a service using its API. Since their API doesn't support multipart/form-data posts in python using the requests library (a pain in the ass), I had to write the post using cURL. My post data has a key with values that are numbers with decimal points. After the post is made, I see that the value of this key gets posted without the decimal point, which leads to a wrong expense post! How can I solve this? Here's the relevant code snippet:
#the data:
PARAMS = {
"total_cost": netto(), #this is the function that returns the cost as float
"created_at": date,
"spent_date": date,
"user": user,
"units": int(1)}
#the curl post with file:
file_path = "./path/myfile.pdf"
command = ["curl", "--location", "--request", "POST", url]
for key, value in headers.items():
command += ["--header", f"{key}: {value}"]
for key, value in PARAMS.items():
command += ["--form", f"{key}={value}"]
command += ["--form", f"receipt=@{file_path}"]
#calling the curl command:
response = subprocess.run(command, stdout=subprocess.PIPE)
So basically after the post is done, the "total_cost" value is posted without the decimal points. Why??
I don't know how to solve this and have never seen this issue.