Last active
April 20, 2016 17:46
-
-
Save jonatasemidio/3e05273bb3a7d9c924da7740cff7adb6 to your computer and use it in GitHub Desktop.
GitHub API Samples Script cURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get a File | |
curl -i -X GET -H 'Authorization: token <your token>' -d '{"path": "index.html", "message": "Initial Commit", "committer": {"name": "Jonatas Emidio", "email": "[email protected]"}, "branch": "master"}' https://api.github.com/repos/jonatasemidio/blog/contents/index.html | |
Create a File | |
curl -i -X PUT -H 'Authorization: token <your token>' -d '{"path": "index.html", "message": "Initial Commit", "committer": {"name": "Jonatas Emidio", "email": "[email protected]"}, "content": "VGVzdGluZyBHaXRIdWIgQVBJ", "branch": "master"}' https://api.github.com/repos/jonatasemidio/blog/contents/index.html | |
Update a File | |
curl -i -X PUT -H 'Authorization: token <your token>' -d '{"path": "index.html", "message": "Initial Commit", "committer": {"name": "Jonatas Emidio", "email": "[email protected]"}, "content": "VGVzdGluZyBHaXRIdWIgQVBJ", "sha":"2706f84a7078ad64fbdca10558879e6f2c323694", "branch": "master"}' https://api.github.com/repos/jonatasemidio/blog/contents/index.html | |
Delete a File | |
curl -i -X DELETE -H 'Authorization: token <your token>' -d '{"path": "post2.txt", "message": "Initial Commit", "committer": {"name": "Jonatas Emidio", "email": "[email protected]"}, "sha":"904dd91b9de4dd50864026f788ac10e05df2d6f1", "branch": "master"}' https://api.github.com/repos/jonatasemidio/blog/contents/post2.txt | |
you can get the sha of your file with the get command. | |
Some URLs: | |
https://developer.github.com/v3/repos/contents/#get-contents | |
As you know, the content of your file need to be in Base64. So use this site to convert: https://www.base64encode.org/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment