Curl将“ -d”参数的一部分视为主机

时间:2018-11-07 17:42:12

标签: windows curl http-post

我正在尝试使用curl对位桶服务器测试一些API。例如,以下调用应在master分支上创建一个标签:

curl https://bitbucket.myserver.com/rest/api/1.0/projects/PRJ/repos/repo-slug/tags \
     -u 'user:pass' \
     -X POST \
     -H 'Content-type: application/json' \
     -d '{"name" : "test-tag", "message": "Test tag from curl", "startPoint": "master" }'

我无法在Windows上运行它(有关详细信息,请参见this question)。同时,发生该错误时,我会得到一些非常奇怪的东西:调用按预期完成,但是curl似乎尝试使用-d参数的值进行操作。完整的输出是这样的:

{"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}curl: (6) Could not resolve host: application
curl: (3) Bad URL, colon is first character
curl: (6) Could not resolve host: test-tag,
curl: (6) Could not resolve host: message
curl: (3) Host name 'Test tag from curl,' contains bad letter
curl: (6) Could not resolve host: startPoint
curl: (6) Could not resolve host: master
curl: (3) [globbing] unmatched close brace/bracket in column 1

为什么会这样?而且,更重要的是,我该如何阻止它?

0 个答案:

没有答案