Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Github API创建组织名称,而不是手动创建?_Git_Curl_Github_Github Api - Fatal编程技术网

如何通过Github API创建组织名称,而不是手动创建?

如何通过Github API创建组织名称,而不是手动创建?,git,curl,github,github-api,Git,Curl,Github,Github Api,我尝试使用GithubAPI来创建组织和存储库,而不是手动创建它们。我正在看这篇文章,它讨论了如何在特定组织下创建存储库 我的github实例url如下-https://github.host.com 我希望我的存储库在创建之后是这样的- https://github.host.com/Mobile/CustomerSystem 这里的Mobile是组织名称,CustomerSystem是存储库名称。在我的例子中,我以前没有创建过Mobile组织名称,因为我想通过Github API以及存储库

我尝试使用GithubAPI来创建组织和存储库,而不是手动创建它们。我正在看这篇文章,它讨论了如何在特定组织下创建存储库

我的github实例url如下-
https://github.host.com

我希望我的存储库在创建之后是这样的-

https://github.host.com/Mobile/CustomerSystem
这里的
Mobile
是组织名称,
CustomerSystem
是存储库名称。在我的例子中,我以前没有创建过
Mobile
组织名称,因为我想通过Github API以及存储库来创建它

因此,我在下面执行curl url,认为它也会在它们下面创建组织名称和存储库,但每次我得到
404时,都找不到
-

curl -i -u david -d '{ "name": "CustomerSystem", "auto_init": true, "private": true, "gitignore_template": "nanoc" }' https://github.host.com/api/v3/orgs/Mobile/repos
下面是我得到的结果-

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"
}
我做错什么了吗

在我看来,如果已经创建了组织名称,那么我上面的CURL调用可以正常工作,并且存储库可以正常创建,没有任何问题。但是如果组织名称不在那里,那么它会给我404错误消息


有没有办法通过github API创建组织名称?在某些情况下,我以前可能已经创建了组织名称,因此我将在它们下面创建新的存储库,但在某些情况下,我以前可能没有创建过组织名称,因此我需要通过Github API创建组织名称。

您可以查看像这样的包装器是如何建议的,以反映当前的情况

您可以列出、获取或编辑组织,但显然不能创建组织

有没有办法通过github API创建组织名称


目前无法通过GitHub API创建组织或用户帐户。

您可以尝试类似的方法

curl --include -u victor-raul-hernandez-contreras:your-personal-access-token-here -X POST https://github.hpe.com/api/v3/admin/organizations --data '{"login":"loko200","profile_name":"lokosoft, inc.", "admin":"victor-raul-hernandez-contreras"}'

我在github enterprise工作时,它很管用

GitHub没有为此提供公共api

但是,如果您想自动化组织创建过程,可以在此页面上检查网络活动(按浏览器中的F12键并导航到“网络”选项卡)

要找到用于检查名称可用性和创建组织的私有api,请将请求导出为curl命令,将其放入shell脚本并参数化组织名称

我不会在这里详细介绍或发布我的脚本,因为脚本编写起来非常简单,它会泄露我的浏览器cookie和会话信息

顺便说一句,如果您使用的是GitHub Enterprise,那么这里会有文档记录

更新:

警告!!!
注意不要创建太多的组织。我目前已经用我的个人帐户创建了500多个组织。现在,每次我登录我的帐户访问github上的页面时,要么需要几秒钟才能加载,要么根本不加载,显示的是unicorn页面。如果我注销我的帐户,页面将再次快速加载。我几乎放弃了使用github web ui

是否可以重命名现有的组织名称。请确认。@LearnHadoop可以通过GitHub API()实现。go gitHub有一个编辑函数()。所以是的。您可以更改名称。但不是它的身份证。谢谢。。我找不到要重命名组织的正确字段。任何想法。@LearnHadoop用于重命名组织的字段是。。。“
name
”。我尝试了以下有效负载。{“description”:“GitHub,公司。”,“name”:“Test-Org-100”}。不走运。实际上,这是GIThub中“组织显示名称”的更改..而不是Repo名称。。