How Do You Create an Issue for a Repository in a GitHub Organization the API?

Problem scenario
You are running this command:

curl -u jdoe:$password -X PUT -d '{"title": "Look at this bug", "body": "This is a serious problem here.", "assignees": [ "jdoe" ], "milestone": 1, "labels": [ "bug" ]}' https://api.github.com/repos/$orgname/$reponame/issues

The message in the response you receive is "Not Found". You found documentation that refers to an "owner" being in the URL. You see "POST /repos/:owner/:repo/issues" (with no reference to the organization). (This was taken from https://developer.github.com/v3/issues/#create-an-issue .)

What should you do to create a GitHub issue with the REST API?

Solution
1. Modify the command.
1.a. Use "POST" instead of "PUT".
1.b. Eliminate the '"milestone": 1,'
1.c. It should look like this:

curl -u jdoe:$password -X POST -d '{"title": "Look at this bug", "body": "This is a serious problem here.", "assignees": [ "jdoe" ], "labels": [ "bug" ]}' https://api.github.com/repos/$orgname/$reponame/issues

2. Run the command after you change the word "jdoe" to the username and the "password" to your GitHub.com password.

Leave a comment

Your email address will not be published. Required fields are marked *