(This is a repost of a stackoverflow answer I once wrote on this topic. Slightly edited. Copied here to make sure I own and store my own content properly.)
curl knows the HTTP method
You normally use curl without explicitly saying which request method to use.
If for whatever reason you’re not happy with these default choices that curl does for you, you can override those request methods by specifying
-X [WHATEVER]. This way you can for example send a DELETE by doing
curl -X DELETE [URL].
It is thus pointless to do
curl -X GET [URL] as GET would be used anyway. In the same vein it is pointless to do
curl -X POST -d data [URL]... But you can make a fun and somewhat rare request that sends a request-body in a GET request with something like
curl -X GET -d data [URL].
(I subsequently used this answer to populate the curl FAQ to cover this.)
Modern versions of curl will inform users about this unnecessary and potentially harmful use of -X when verbose mode is enabled (
-v) – to make users aware. Further explained and motivated here.
-G converts a POST + body to a GET + query
You can ask curl to convert a set of
-d options and instead of sending them in the request body with POST, put them at the end of the URL’s query string and issue a GET, with the use of `-G. Like this:
curl -d name=daniel -d grumpy=yes -G https://example.com/
… which does the exact same thing as this command: