57

我正在尝试在命令提示符中执行以下行:

curl -X POST -d '{ "method" : "account_info", "params" : [ { "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"} ] }' http://s1.ripple.com:51234

但是,我得到以下信息:

curl: (6) Could not resolve host: method
curl: (7) Failed connect to :80; No error
curl: (6) Could not resolve host: account_info,
curl: (6) Could not resolve host: params
curl: (7) Failed connect to :80; No error
curl: (3) [globbing] illegal character in range specification at pos 2
curl: (3) [globbing] unmatched brace at pos 2
curl: (6) Could not resolve host: account
curl: (7) Failed connect to :80; No error
curl: (3) [globbing] unmatched close brace/bracket at pos 35
curl: (3) [globbing] unmatched close brace/bracket at pos 1
curl: (3) [globbing] unmatched close brace/bracket at pos 1
unable to parse request

我在 Windows 上,错误与引号、大括号和通配符有关。我尝试通过在引号前面加上反斜杠来转义引号,但没有成功。

4

5 回答 5

84

不要使用单引号。使用 .转义字符串中的任何双引号\

curl -X POST -d "{ \"method\" : \"account_info\", \"params\" : [ { \"account\" : \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\"} ] }" http://s1.ripple.com:51234

Windowcommand.exe似乎不支持单引号。PowerShell 可以,但是在使用的时候还是会出现一些问题,所以最好的解决办法就是根本不使用它们。

于 2013-07-10T01:12:35.803 回答
48

您可以使用curl -g关闭通配符:

curl -g -X POST -d '{ "method" : "account_info", "params" : [ { "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"} ] }' http://s1.ripple.com:51234

比转义所有这些括号更容易。

于 2014-05-08T16:48:31.093 回答
2

尝试基本的发布一些东西。

curl -X POST --data '{"username":"username", "password":"password"}' --header "Content-Type:application/json" http://127.0.0.1:8000/your_url/
于 2018-07-06T07:37:11.843 回答
1

对于 Windows 用户:您可以下载 git bash 以运行以下 curl 命令。

curl http://localhost:8080/subpage --include --header "Content-Type: application/json" --request "POST" --data '{"variable": "value"}
于 2021-09-21T11:58:51.373 回答
0

在上面的回复中,需要注意的是数据是以 JSON 格式指定的,这需要指定--headerAlokanswer

也可以像这样以“url”格式定义它:

curl -X POST --data "method=account_info&params=[…]" http://s1.ripple.com:51234

并避免指定--header "Content-Type…"

于 2019-10-08T14:49:16.310 回答