php - 验证 unix cURL 命令
问题描述
我对 cURL 比较陌生。我有一个 cURL 命令将 csv 上传到 API 端点。这是卷曲,
curl 'https://api.myweb.tld/something/upload' \
-X POST \
-H 'Authorization: Basic SomeRandomTokenIHaveReceived' \
-H 'ContentType: multipart/formdata' \
-F 'csv=@./the_file.csv' \
-F 'encoding=windows1252' \
-F 'fieldSeparator=,' \
-- compressed | json_pp > response.json
它所做的只是将 csv 中的值传递给 API 端点。并在 response.json 中接收响应以了解操作是否成功。
我在 OSX 终端上运行它并在 response.json 文件中得到这个响应
{
"type" : "APIException",
"message" : "Method 'GET' not allowed. Allowed methods are: POST,OPTIONS.",
"identifier" : 70004,
"statusCode" : 405
}
我还在终端中收到一些警告,如下所示:
curl: (6) Could not resolve host: X
curl: (6) Could not resolve host: POST
curl: (6) Could not resolve host: H
curl: (3) Port number ended with ' '
curl: (6) Could not resolve host: H
curl: (3) Port number ended with ' '
curl: (6) Could not resolve host: F
curl: (7) Failed to connect to port 80: Connection refused
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: encoding=windows1252
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: fieldSeparator=,
curl: (6) Could not resolve host: compressed
谁能指出它有什么问题?我需要别的东西来执行这个吗?如果我想在 PHP 中运行它,它是如何工作的?我只是不太熟悉 cURL 及其性质,如果有人能给我一些提示,我会很高兴。
谢谢大家!
解决方案
推荐阅读
- python - POST 请求在 repl.it 上返回 HTTP 错误 308
- python - rpc 错误:代码 = 不可用 desc = 上游连接错误或在标头之前断开/重置。重置原因:协议错误
- json - 在 Scala 中验证 JSON
- flutter - 参数类型“MaterialColor”不能分配给参数类型“MaterialStateProperty”
- c# - 不同格式的 JSON 反序列化为对象
- javascript - 如何在 js 中为许多值使用 :not() 选择器
- javascript - 与节点雪花-sdk、asn1 连接的问题
- vmware - MACOS 安装程序 -pkg 卡住
- php - 通过表格跟踪 DHL 的交付状态
- reactjs - REACTJS - GSAP“toArray”函数不适用于动态标记