如何通过Github API创建组织名称,而不是手动创建? [英] How to create Organization name through Github API instead of creating manually?

查看:243
本文介绍了如何通过Github API创建组织名称,而不是手动创建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用github api来创建组织和存储库,而不是手动创建它们。我在查看此网站,其中介绍了如何创建

I am trying to use github api to create organization and repositories instead of creating them manually. I was looking at this site which talks about how to create repositories under a particular organization.

我的github实例url就是这样 - https://github.host.com

My github instance url is like this - https://github.host.com

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

And I want my repository to be like this after getting created -

https://github.host.com/Mobile/CustomerSystem

这里 Mobile 是组织名称, CustomerSystem 是存储库名称。在我的情况下,我没有 Mobile 之前已经创建的组织名称,因为我想通过Github API以及存储库创建它。

Here Mobile is the organization name and CustomerSystem is the repository name. In my case, I don't have Mobile organization name already created before as I want to create it through Github API along with repository as well.

所以我执行下面的curl url认为它会创建组织名称和存储库下,以及,但每次我得到 404未找到 -

So I am executing below curl url thinking it will create organization name and repository under them as well but everytime I am getting 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

以下是我得到的结果 -

Below is the result I am getting -

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错误消息。

It looks to me if organization name is already created, then my above CURL call works fine and the repository gets created fine without any issues. But if the organization name is not there already then it gives me 404 error message.

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

Is there any way to create organization name as well through github API? In some cases, I might have Organization name already created before, so I will create new repository under them but in some cases, I might not have Organization name already created before so I need to create Organization name through Github API.

推荐答案

您可以查看如 go-gihub 建议管理组织,反映组织API

You can check out how a wrapper like go-gihub proposes to manage an organization, reflecting the Organization API.

您可以列出,获取或编辑单位,但显然不是

You can list, get or edit an organization, but apparently not create one.

这篇关于如何通过Github API创建组织名称,而不是手动创建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆