2015-02-08 31 views
1

我正在嘗試使用github API來創建組織和存儲庫,而不是手動創建它們。我在看這site談論如何創建特定組織下的存儲庫。如何通過Github API創建組織名稱而不是手動創建?

我的github例如URL是這樣的 - https://github.host.com

而且我想我的倉庫是這樣得到創建後 -

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

這裏Mobile是組織名稱和CustomerSystem是倉庫名。在我的情況下,我沒有Mobile組織名稱,因爲我想通過Github API以及存儲庫創建組織名稱。

所以我執行下面捲曲網址以爲它會根據他們創建的組織名稱和資源庫和,但每次我得到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 

下面是我得到的結果 -

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創建組織名稱。

回答

2

有沒有辦法通過github API創建組織名稱?

目前無法通過GitHub API創建組織或用戶帳戶。

0

你可以嘗試這樣的

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上的企業工作了我的東西。