QProcess curl 和 github REST api

QProcess curl and the github REST api

我正在尝试使用 GitHub REST API 在回购中创建问题。我正在使用以下命令:

curl -u "marcusbritanicus:pass" https://api.github.com/repos/marcusbritanicus/apitrial/issues -XPOST -H 'Content-Type: application/json' -d@issue.json

这完全符合预期。但是,当我使用 QProcess 执行相同的命令时,我得到 {"message": "Bad credentials", "documentation_url": "https://developer.github.com/v3"}

这就是我使用 QProcess(Python/Qt4 Debian Sid 上的 2.7.14/4.12.1)的方式:

>>> proc = QProcess()
>>> proc.setProcessChannelMode( QProcess.MergedChannels )
>>> args = [ "-u", "'marcusbritanicus:password'", "https://api.github.com/repos/marcusbritanicus/apitrial/issues", "-XPOST", "-H", "'Content-Type: application/json'", "-d@issue.json" ]
>>> proc.start( "curl", args )
>>> proc.waitForFinished()
>>> proc.readAll()

我是不是做错了什么?

问题是由您的凭据周围的引号引起的(''),如果它们位于参数的开头和结尾,则没有必要使用它们。

proc = QProcess()
proc.setProcessChannelMode( QProcess.MergedChannels )
args = [ "-u", "marcusbritanicus:password", "https://api.github.com/repos/marcusbritanicus/apitrial/issues", "-XPOST", "-H", "Content-Type: application/json", "-d@issue.json" ]
proc.start( "curl", args )
proc.waitForFinished()
proc.readAll()