【问题标题】:GitHub create repository via curl "Problem parsing JSON"GitHub 通过 curl“解析 JSON 问题”创建存储库
【发布时间】:2021-06-13 15:26:48
【问题描述】:

我想通过 curl 创建一个新的 GitHub 存储库,但我总是收到错误:“Problems parsing 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 github-api


    【解决方案1】:

    我自己想通了,问题是操作系统。 在 Windows 上,我必须在 -d 之后替换单引号 ' 并在末尾用双引号 " 并且我必须对双引号使用反斜杠。 工作命令如下:

    curl -u "username:token" https://api.github.com/user/repos -d "{\"name\":\"test\",\"private\":true}"
    

    【讨论】:

      猜你喜欢
      • 2016-02-27
      • 1970-01-01
      • 2022-12-24
      • 2015-04-07
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      • 2017-04-06
      相关资源
      最近更新 更多