POST csv/Text file using cURL POST csv/Text file using cURL flask flask

POST csv/Text file using cURL


There are many alternate ways to accomplish this. One way isI have used the following:

curl -F ‘data=@<file_location>’ <URL>

Eg. curl -F data=@data.csv localhost:5000/h

Your command can also be changed slightly like this

curl -X POST -H 'Content-Type: text/csv' -d @file.csv http://localhost:5000/upload

The above is one of the many ways.It can be sent either as a part of form or data, or multipart, etc. You can refer Medium Post


Curl's default Content-Type is application/x-www-form-urlencoded so your problem is probably that the data you are POSTing is not actually form data. It might work if you set the content type header properly:

-H "Content-Type: text/csv"

Though it does depend on the server.