Home > front end >  Curl -X in GET and POST request. Do I need -X?
Curl -X in GET and POST request. Do I need -X?

Time:06-16

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/.

CodePudding user response:

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

  • Related