Unix中的curl命令给出异常

时间:2018-11-21 10:37:59

标签: curl

我正在执行以下curl命令并收到错误消息:

curl -Method Post -Header @{'Content-Type'='application/x-www-form-urlencoded'}-Body @{grant_type = 'password';username = 'abcd';password = 'xyz'} "http://someaddress/api/oauth/token" -O test_curl

请问我在这里做错什么了吗?

错误:

Warning: built-in manual was disabled at build-time!
curl: option -Method: is unknown
curl: try 'curl --help' for more information

1 个答案:

答案 0 :(得分:1)

-Method选项应为-X--request-Header选项应为-H--header。另外,您必须使用双引号将带有单引号的JSON标头传递到curl

尝试一下:

curl -XPOST -H "@{'Content-Type'='application/x-www-form-urlencoded'}-Body @{grant_type = 'password';username = 'abcd';password = 'xyz'}" -o test_curl "http://someaddress/api/oauth/token"