Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
901 views
in Technique[技术] by (71.8m points)

git - How to create Organization name through Github API instead of creating manually?

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.

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

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.

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

Is there anything wrong I am doing?

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Is there any way to create organization name as well through github API?

Currently it's not possible to create organizations nor user accounts via the GitHub API.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...