Skip to content

Instantly share code, notes, and snippets.

@JeffPaine
Created July 19, 2012 17:24
Show Gist options
  • Select an option

  • Save JeffPaine/3145490 to your computer and use it in GitHub Desktop.

Select an option

Save JeffPaine/3145490 to your computer and use it in GitHub Desktop.
Make an issue on github using API V3 and Python
import json
import requests
# Authentication for user filing issue (must have read/write access to
# repository to add issue to)
USERNAME = 'CHANGEME'
PASSWORD = 'CHANGEME'
# The repository to add this issue to
REPO_OWNER = 'CHANGEME'
REPO_NAME = 'CHANGEME'
def make_github_issue(title, body=None, assignee=None, milestone=None, labels=None):
'''Create an issue on github.com using the given parameters.'''
# Our url to create issues via POST
url = 'https://api.github.com/repos/%s/%s/issues' % (REPO_OWNER, REPO_NAME)
# Create an authenticated session to create the issue
session = requests.session(auth=(USERNAME, PASSWORD))
# Create our issue
issue = {'title': title,
'body': body,
'assignee': assignee,
'milestone': milestone,
'labels': labels}
# Add the issue to our repository
r = session.post(url, json.dumps(issue))
if r.status_code == 201:
print 'Successfully created Issue "%s"' % title
else:
print 'Could not create Issue "%s"' % title
print 'Response:', r.content
make_github_issue('Issue Title', 'Body text', 'assigned_user', 3, ['bug'])
@datatalking
Copy link
Copy Markdown

I'll test this script this weekend, its got me thinking of ways to improve upon what you did.

  1. Creating a database of choices
  2. Add this code to my data_workbench when I do EDA.

@aN4ksaL4y
Copy link
Copy Markdown

Hi, Do you have an updated version of it? For example: session = requests.session(auth=(USERNAME, PASSWORD)) is not working with an error: TypeError: session() takes no arguments (1 given)

I changed it to "session = requests.Session(auth=(USERNAME, PASSWORD)) " and still it fails with an error: TypeError: init() got an unexpected keyword argument 'auth'

any help is much appreciated.

try this bud, my latest gist post

@vipulgupta2048
Copy link
Copy Markdown

If you like to upload images to a GitHub issue, you can use gitshot: uses release assets + CLI to post images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment