I'm looking to use the Python requests library to create a new file in a GitHub repository. Entering the following in the command line works for me (replacing LOGIN and TOKEN as appropriate):
curl -X PUT -d '{"path": "testfile.txt", "message": "test", "content": "aGVsbG8y"}' https://api.github.com/repos/LOGIN/testrepo/contents/testfile.txt\?access_token\=TOKEN
But I keep running into the "Problems parsing JSON" error (status code 400) when attempting the same with requests:
data = {
"message": "test",
"content": "aGVsbG8y",
"path": "testfile.txt"
}
url = "https://api.github.com/repos/LOGIN/testrepo/contents/testfile.txt?access_token={}".format(TOKEN)
response = requests.put(url, data=data)
Any hints as to what I'm doing differently? I've checked through the similar questions, but haven't found the right tweak. Thanks!