Skip to content

Instantly share code, notes, and snippets.

@Aldaviva
Last active May 19, 2022 14:16
Show Gist options
  • Save Aldaviva/4c8202d325e2915b1eebd591138874ff to your computer and use it in GitHub Desktop.
Save Aldaviva/4c8202d325e2915b1eebd591138874ff to your computer and use it in GitHub Desktop.
Curl Cheat Sheet: How is anyone supposed to remember curl commands? I hate command-line utilities.

curl cheat sheet

$ curl [arguments] 'https://my.url.com/path/file.ext?a=b&c=d'

Request

Nickname Argument Description
Insecure -k Accept invalid TLS server certificates
Verb/Method -X POST Set the request verb
Header -H "Content-Type: application/json" Add a request header
Auth -u username:password Send authentication
Body -d "<hello />" Set the request body to a string
Body -T requestBody.xml Set the request body to a local file's contents

Response

Nickname Argument Description
Verbose -v Show verbose output, including TLS, keepalive, and all headers
Quiet -s Hide all output except the response body
Headers -i Show response headers
Redirections -L Follow redirection responses
Output -o response.txt
-O
Save the response to a local file instead of printing to standard output

URL

Remember to either escape all instances of & in the URL into \&, or surround the URL with 'single quotation marks', because otherwise Bash will assume you want to background the command before the ampersand and then run the right side as a separate command, instead of treating the entire URL as one string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment