joh*_*ohn 2 git curl github github-api
我正在尝试使用 github api 创建组织和存储库,而不是手动创建它们。我正在查看这个网站,其中讨论了如何在特定组织下创建存储库。
我的 github 实例 url 是这样的 -https://github.host.com
我希望我的存储库在创建后是这样的 -
https://github.host.com/Mobile/CustomerSystem
Run Code Online (Sandbox Code Playgroud)
这Mobile是组织名称,CustomerSystem也是存储库名称。就我而言,我之前没有Mobile创建组织名称,因为我也想通过 Github API 以及存储库来创建它。
所以我在下面执行curl url,认为它也会在它们下创建组织名称和存储库,但每次我得到404 Not Found-
curl -i -u david -d '{ "name": "CustomerSystem", "auto_init": true, "private": true, "gitignore_template": "nanoc" }' https://github.host.com/api/v3/orgs/Mobile/repos
Run Code Online (Sandbox Code Playgroud)
以下是我得到的结果 -
HTTP/1.1 404 Not Found
Server: GitHub.com
Date: Sat, 07 Feb 2015 20:43:32 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 102
Status: 404 Not Found
X-GitHub-Media-Type: github.v3
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
Content-Security-Policy: default-src 'none'
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
X-GitHub-Request-Id: fv4af52e-617c-4ga1-br2f-5cb51b1df3bb
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/enterprise/2.0/v3"
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么吗?
在我看来,如果组织名称已经创建,那么我上面的 CURL 调用就可以正常工作,并且存储库可以正常创建,没有任何问题。但如果组织名称不存在,则会显示 404 错误消息。
有没有办法也通过 github API 创建组织名称?在某些情况下,我之前可能已经创建了组织名称,所以我将在它们下创建新的存储库,但在某些情况下,我之前可能没有创建组织名称,所以我需要通过 Github API 创建组织名称。
| 归档时间: |
|
| 查看次数: |
4552 次 |
| 最近记录: |