我对cURL比较陌生。 我有一个cURL命令,将csv上传到API端点。 这是cURL,
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及其本质,如果有人可以给我一些提示,我将很高兴。
谢谢!