Github API错误-{“ message”:“ Not Found”,“ documentation_url”:“ https://developer.github.com/v3”}在cURL终端中进行回购

时间:2019-10-10 04:21:08

标签: curl github github-api

api是v3,我尝试制作一个工具的原因是,这样当您输入github的用户名和密码以及存储库名称和描述时,它将初始化存储库并为您提供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

我得到了答复

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3"
}

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

2 个答案:

答案 0 :(得分:2)

有关您的GitHub API调用,请参见此curl tutorial

  

POST

     

--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
  

当然--data表示POST,因此您不必也指定--request标志

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

答案 1 :(得分:0)

好的,我明白了。我只是使用了错误的网址。这就是我所做的

curl --user "{user}:{password}" -X POST -d '{"name":"api-test","description":"made with github api","private":"true","homepage":"https://github.com"}' \\ https://api.github.com/user/repos // <- IMPORTANT PART