4

In a project I have seen colleagues setting the -X parameter in a GET CURL request. I admit that I am not an expert and I had always fired my requests without this parameter. And it worked. I know about X that it stands for request. But nothing more.

Now my question. Is it necessary to include the X parameter and if so why?

curl GET http://localhost:3000/api/projects/ instead of curl -X GET http://localhost:3000/api/projects/.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
Max Pattern
  • 1,430
  • 7
  • 18
  • Does this answer your question? [curl -GET and -X GET](https://stackoverflow.com/questions/8498371/curl-get-and-x-get) – shabunc Jun 16 '22 at 09:23

1 Answers1

15

No. You normally should not use -X at all with curl. If you want a GET request, just specify the URL as GET is the default. If you want POST, you use -d or -F (but no -X) etc.

See https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/

Also related: curl -GET and -X GET

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222