我想通过curl创建一个新的GitHub存储库,但我总是收到错误:"解析JSON的问题";
curl -u "username:token" https://api.github.com/user/repos -d '{"name":"test","private":true}'
错误:
{
"message": "Problems parsing JSON",
"documentation_url": "https://docs.github.com/rest/reference/repos#create-a-repository-for-the-authenticated-user"
}
但只有当我使用windows 10时才会出现错误。我试着在我的linux操作系统上执行完全相同的命令,一切都很好。
我自己想明白了,问题出在操作系统上。在windows上,我必须将-d之后和末尾的单引号替换为双引号;我必须用反斜杠来表示双引号。工作命令看起来像:
curl -u "username:token" https://api.github.com/user/repos -d "{"name":"test","private":true}"
我也在windows上。我有同样的错误,无法使用您的解决方案使其正常工作。只要稍微调整一下,我就可以工作了。
我用单引号包围了负载,并转义了json负载中的双引号。
curl -u "username:token" https://api.github.com/user/repos -d '{"name":"test","private":true}'