6

api is v3, the reason that I am trying to make a tool so that when you input your username and password for github and the repo name and description, it will initialize the repo and give you the url. My input is this -

curl -u {myuser}:{mypassword} -H "Content-Type: application/json" -d '{"name":"api-test","description":"made with github api","homepage": "https://github.com","private":true}' POST https://api.github.com/users/{myuser}/repos

I get the response

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3"
}

. The docs say this : Creates a new repository for the authenticated user. POST /user/repos. https://developer.github.com/v3/repos/#create. I am very new to github-api, and thankful for help.

2 Answers 2

2

See this curl tutorial for your GitHub API calls

POST

Use the --request (-X) flag along with --data (-d) to POST data

curl --user "caspyin" --request POST --data '{"description":"Created via API","public":"true","files":{"file1.txt":{"content":"Demo"}}' https://api.github.com/gists

curl --user "caspyin" -X POST --data '{"description":"Created via API","public":"true","files":{"file1.txt":{"content":"Demo"}}' https://api.github.com/gists

Of course --data implies POST so you don't have to also specify the --request flag

curl --user "caspyin" --data '{"description":"Created via API","public":"true","files":{"file1.txt":{"content":"Demo"}}' https://api.github.com/gists
Sign up to request clarification or add additional context in comments.

Comments

0

ok i got it. I just used the wrong url. This is what I did

curl --user "{user}:{password}" -X POST -d '{"name":"api-test","description":"made with github api","private":"true","homepage":"https://github.com"}' \\ https://api.github.com/user/repos // <- IMPORTANT PART

1 Comment

Yes, that is what I mention in my answer, plus the fact you used POST without the -X.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.