我有以下命令,当我将其输入浏览器时效果很好
http://192.168.2.13:8092/jsonrpc?request={"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.testscript"},"id":"1"}}
但是我想在终端窗口中使用curl来调用它。我试过这个......
curl http://192.168.2.13:8092/jsonrpc?request={"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.testscript"},"id":"1"}}
但它给了我以下错误信息..
curl: (3) [globbing] unmatched close brace/bracket in column 52
curl: (3) [globbing] unmatched close brace/bracket in column 67
curl: (3) [globbing] unmatched close brace/bracket in column 75
curl: (3) [globbing] unmatched close brace/bracket in column 45
我哪里错了?
答案 0 :(得分:0)
使用Curl发布JSON数据的语法
curl --data '{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.testscript"},"id":"1"}}' http://192.168.2.13:8092/jsonrpc?request
答案 1 :(得分:0)
最后还有一个额外的括号。
此外,您应该将URL表示为URL编码。在浏览器中输入数据会自动将URL转换为URL编码(在大多数情况下)。
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
答案 2 :(得分:0)
curl在内部使用--data-urlencode:
支持url-encoding$ curl -G -v" http://localhost:30001/data" --data-urlencode" msg = hello world" -G也需要将数据附加到URL。
https://unix.stackexchange.com/questions/86729/any-way-to-encode-the-url-in-curl-command