如何更改我的 cURL 调用以识别 1 个以上的参数?

How can I change my cURL call to recognise more than 1 parameter?

我想进行以下 curl 调用以获取访问令牌:

curl -k -XPOST --user "{user}" {url}/access_token -d 'grant_type=authorization_code&code={code}&redirect_uri={uri}' 

但是,我收到以下错误说明:

'code' is not recognized as ane internal or external command, operable program or batch file.
'redirect_uri' is not recognized as ane internal or external command, operable program or batch file.

当我检查跟踪时,我看到主体只包含这个:'grant_type=authorization_code

我该怎么做才能确保所有参数都通过?

&-字符似乎被解释为"execute as background job"。尝试使用反斜杠转义每个 &-字符 - 例如 \&

或者您可以将您的内容写入文件并通过参数 -d @file 引用该文件 @ 字符对于 curl 知道文件是文件名很重要。

curl -X "POST" "{url}/access_token" \
 --user "{user}" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 --data-urlencode "code={code}" \
 --data-urlencode "redirect_uri={uri}" \
 --data-urlencode "grant_type=authorization_code"

希望对您有所帮助