Skip to content

Instantly share code, notes, and snippets.

@wakproductions
Created March 26, 2018 05:00
Show Gist options
  • Save wakproductions/7c5c767a9fd8787d1603b00dd709c44f to your computer and use it in GitHub Desktop.
Save wakproductions/7c5c767a9fd8787d1603b00dd709c44f to your computer and use it in GitHub Desktop.
Curl Cheat Sheet

Get request

Download file

curl -o website https://domain.com curl -O https://domain.com/file.zip

Header Only

curl -I http://domain.com

Header and response (verbose)

curl -i http://domain.com

Post with parameters

curl -F "p1=value1" -F "p2=value2" "http://myurl.com/program" -or- curl -d “firstname=Bob” -d “lastname=Jones” http://echo.httpkit.com

-F sets the content type to multipart/form-data. When paired with the @ you can send files

Set Request Method

curl -X POST echo.httpkit.com curl -X DELETE echo.httpkit.com

Set Headers

curl -H “Content-Type: text/json” -H “Accept: application/json" curl -H “Authorization: OAuth 2c4418dksjd” http://echo.httpkit.com

Request body

Use the -d flag You can read from a file using @ curl -X POST -H ‘Content-Type: application/json’ -d @example.json echo.httpkit.com

from a file example: curl --data "@/path/to/filename" http://...

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