postman 如何使用curl发送带有POST请求的文件?

h7wcgrx3  于 2022-11-07  发布在  Postman
关注(0)|答案(1)|浏览(338)

我正在尝试使用POST请求发送一个文件,curl:

curl -v -u admin:admin -X POST -H 'Content-Type: application/xml' --data-binary '@test.xml'  'http://localhost:10215/'

我收到以下错误:

Note: Unnecessary use of -X or --request, POST is already inferred.

* Could not resolve host: application
* Closing connection 0

curl: (6) Could not resolve host: application
Note: Unnecessary use of -X or --request, POST is already inferred.

* Could not resolve host: 'http
* Closing connection 1

curl: (6) Could not resolve host: 'http

通过Postman,我设法发送了文件,在请求的正文中添加了文件内容。但是我如何更新curl命令,以便能够从我运行命令的文件夹中发送文件呢?身份验证是基本的身份验证,必须指定请求的Content-Type。

g6ll5ycj

g6ll5ycj1#

如果你已经用postman实现了它,只需复制由postman点击代码按钮生成的curl代码:

相关问题