Skip to content

Instantly share code, notes, and snippets.

@cybersamx
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cybersamx/10a389381e069e689a18 to your computer and use it in GitHub Desktop.
Save cybersamx/10a389381e069e689a18 to your computer and use it in GitHub Desktop.
Commonly used CURL commands for testing/debugging
# GET a JSON result.
curl -i -H "Accept: Application/json" -H "Content-Type: application/json" http://localhost/sessions.json
# POST a JSON result.
curl -X POST -H "Accept: Application/json" -H "Content-Type: application/json" -d '{"id":"IDVALUE","name":"Sam"}' http://localhost/sessions.json
# Use cookies (write/read).
curl -c cookies.txt -b cookies.txt http://localhost/users.json
# Follow redirection.
curl -L http://localhost
# Add a custom header Authorization.
curl --header "Authorization: MyAPIKey" http://localhost/users.json
# Reference <http://stackoverflow.com/questions/14978411/http-post-and-get-using-curl-in-linux>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment