Github API 错误 - { "message": "Not Found", "documentation_url": "https://developer.github.com/v3" } 在 cURL 终端中制作 repo

Mai*_*e13 5 curl github github-api

api 是 v3,我试图制作一个工具的原因是当你输入你的 github 用户名和密码以及 repo 名称和描述时,它会初始化 repo 并给你 url。我的输入是这个 -

curl -u {myuser}:{mypassword} -H "Content-Type: application/json" -d '{"name":"api-test","description":"made with github api","homepage": "https://github.com","private":true}' POST https://api.github.com/users/{myuser}/repos
Run Code Online (Sandbox Code Playgroud)

我得到回应

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3"
}
Run Code Online (Sandbox Code Playgroud)

. 文档是这样说的:为经过身份验证的用户创建一个新的存储库。POST /用户/存储库。https://developer.github.com/v3/repos/#create。我对 github-api 很陌生,感谢您的帮助。

Von*_*onC 2

有关 GitHub API 调用,请参阅此curl 教程

邮政

使用--request( -X) 标志和--data( -d) 来获取POST数据

curl --user "caspyin" --request POST --data '{"description":"Created via API","public":"true","files":{"file1.txt":{"content":"Demo"}}' https://api.github.com/gists

curl --user "caspyin" -X POST --data '{"description":"Created via API","public":"true","files":{"file1.txt":{"content":"Demo"}}' https://api.github.com/gists
Run Code Online (Sandbox Code Playgroud)

当然 --data 意味着 POST 所以你不必同时指定 --request 标志

curl --user "caspyin" --data '{"description":"Created via API","public":"true","files":{"file1.txt":{"content":"Demo"}}' https://api.github.com/gists
Run Code Online (Sandbox Code Playgroud)