if I do a POST request on Postman with my local API server it works:
But if I try in python with this syntax it doesn’t work:
requests.post('http://127.0.0.1:5001/api/v0/add', data={'path': 'test'}).text
it returns:
"file argument 'path' is requiredn"
Can you please explain me why it doesn’t work?
Advertisement
Answer
The issue is that using data on requests.post defaults to application/x-www-form-urlencoded while your application wants multipart/form-data. Try using files instead of data:
requests.post('http://127.0.0.1:5001/api/v0/add', files={'path': 'test'}).text
						