【问题标题】:Curl command is syntactically incorrectCurl 命令在语法上不正确
【发布时间】:2019-11-20 16:59:25
【问题描述】:

我尝试在邮递员中导入 curl 命令,但它给出类型错误。

curl -X POST -k foo:foosecret@localhost:9000/hascode/oauth/token \
   -d grant_type=password -d client_id=foo -d client_secret=abc123 \
   -d redirect_uri=https://www.hascode.com -d username=bar -d password=barsecret

截图如下:

【问题讨论】:

  • 内容中有2个\,好像是从别处复制过来的?
  • 是的,它的复制品,我没有它的正确知识。我已经尝试删除 2 \ 但仍然是同样的问题。

标签: curl postman


【解决方案1】:

curl命令有几个问题:

  • \ 应该被删除。它是从其他地方复制的(作为换行符)。
  • HTTP 协议丢失,应该是http://localhost:9000
  • 出现多个-d。只需要一个-d
  • 数据https://www.hascode.com 未编码。

可以导入 postman 的有效 curl 命令如下所示(如果您的服务器接受 application/x-www-form-urlencoded content-type):

curl -X POST http://foo:foosecret@localhost:9000/hascode/oauth/token -H 'Content-Type: application/x-www-form-urlencoded' -d 'grant_type=password&client_id=foo&client_secret=abc123&redirect_uri=https%3A%2F%2Fwww.hascode.com&username=bar&password=barsecret'

【讨论】:

    猜你喜欢
    • 2019-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-04
    • 1970-01-01
    • 2020-10-12
    • 1970-01-01
    相关资源
    最近更新 更多