githubgithub-apigist

How to create a gist on command line


I am trying to create a gist from bash, and I have tried many versions scripts I could get, but none are working.

This seems like a correct one, but it does not work also.

curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists

I have a test.txt file with content I would like to create the gist, but it won't work. It says, invalid email, if I try to add -u USER or -u USER:PASS it still won't work saying "message": "Problems parsing JSON", ..

I don't know what is wrong. the documentation does not provide much except for this line:

POST /gists as you can see, I am passing the test.txt file.


Solution

  • I've just tried

    curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' -u mgarciaisaia:mypassword https://api.github.com/gists
    

    and it worked: https://gist.github.com/mgarciaisaia/fa51238073eb2cf508aa

    I don't see any problem in your command.