Skip to content

Instantly share code, notes, and snippets.

@albert-zhang
Last active February 8, 2017 03:43
Show Gist options
  • Save albert-zhang/f0a91b7728507aaf5e2c2f58277b279e to your computer and use it in GitHub Desktop.
Save albert-zhang/f0a91b7728507aaf5e2c2f58277b279e to your computer and use it in GitHub Desktop.
curl

POST JSON

curl -H "Content-Type: application/json" -X POST -d '{"key":"value"}' http://example.com

http://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest

POST File

curl -X POST -d @/path/to/myfile http://example.com

http://stackoverflow.com/questions/3007253/send-post-xml-file-using-curl-command-line

POST Multipart

curl \
    -F "key1=1" \
    -F "key2=2" \
    -F "file=@/path/to/myfile" \
    http://example.com

http://stackoverflow.com/questions/12667797/using-curl-to-upload-post-data-with-files

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