My Profile Photo

Deniz G


Bilingual Blog: Turkish and English on Software and Life.


curl -GET vs -XGET

You maybe realize that there are some requests like -GET and -XGET if you use curl. It creates the complexity about using http methods. Do I need to use XGET or GET? The question is simple.

There are some supported http methods, but for example there is no delete which used many of us. If you type like “curl -DELETE”, it sends GET request. To address this problem, you will predefined -X before your method name like -XDELETE.

This style says curl that “hey man, I want to make request with exactly this method even if you don’t support this. Don’t change it.” So, curl configures the method name behind the -X option. In this perspective, there is no difference between -GET and -XGET because curl supports GET request.

There is a sample rest api for testing purpose in internet. You can visit it from here.

curl -DELETE https://reqres.in/api/users/2 => it uses “get single user api” (GET /api/users/2)

curl -XDELETE https://reqres.in/api/users/2 => it works as expected.