使用cURL POST csv /文本文件 [英] POST csv/Text file using cURL
问题描述
如何使用 cURL
localhost 上运行的服务器>。
How can I send POST request with a csv or a text file to the server running on a localhost
using cURL
.
我尝试了 curl -X POST -d @ file.csv http:// localhost:5000 / upload
但我得到
{
message:浏览器(或代理)发送了该服务器无法理解的请求。
}
{ "message": "The browser (or proxy) sent a request that this server could not understand." }
我的服务器是 flask_restful API
。
推荐答案
有很多其他方法可以完成此操作。一种方式是
我使用了以下内容:
There are many alternate ways to accomplish this. One way is I have used the following:
curl -F ‘data=@<file_location>’ <URL>
例如。 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
以上是多种方式之一,可以作为您可以参考 Medium Post
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 POST csv /文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!