Skip to content

Instantly share code, notes, and snippets.

@bolerap
Created November 8, 2016 04:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bolerap/221e834872b9313886ae82baac662ef8 to your computer and use it in GitHub Desktop.
Save bolerap/221e834872b9313886ae82baac662ef8 to your computer and use it in GitHub Desktop.
# Send POST request with data to github api to create a gist
curl --user "<username>" --request POST --data '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# or in short
curl -u "<username>" -X POST -d '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# or more short, if supplied -d (data) POST method can ommited as below
curl -u "<username>" -d '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# Send POST request with multiple data
curl --data "login=<username>" --data "token=<token_string>" https://github.com/api/v2/json/user/show/<username>
# or combine into single --data
curl --data "login=<username>&token=<token_string>" https://github.com/api/v2/json/user/show/<username>
# Send POST request with data read from a file (@/@-)
curl --user "<username>" --data @file.txt https://api.github.com/gists
# or read from STDIN -> ctrl+d to finish enter data
curl --user "<username>" --data @- https://api.github.com/gists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment