Reputation: 399
When I try to create an issue with the python requests module, it returns the problem {"message":"Problems parsing JSON","documentation_url":"https://developer.github.com/v3"}
here is the code I use:
user = <My user>
pswd = <My password>
ses = requests.Session()
ses.auth = (user, pswd)
issue = {"title": "Hello World",
"body": "omg",
"assignee": <My user>,
"milestone": None,
"labels": ["label", "friend"]
}
l = json.dumps(issue)
r = ses.post("https://api.github.com/repos/<My user>/<My repo>", params=l)
Of course I replaced the things in <>
for the actual user and repo, I put it like that here for privacy reasons
Upvotes: 0
Views: 2174
Reputation: 45352
Use json
parameter to send JSON document and POST
to /repos/:owner/:repo/issues
:
import requests
import json
user = "username"
pswd = "password"
repo = "your-repo"
ses = requests.Session()
ses.auth = (user, pswd)
issue = {
"title": "Hello World",
"body": "omg",
"assignee": user,
"milestone": None,
"labels": ["label", "friend"]
}
issue_url = "https://api.github.com/repos/" + user + "/" + repo + "/issues"
r = ses.post(issue_url, json = issue)
Upvotes: 2