curl GET
curl http://www.mydomain.com/testWith Parameter
curl http://www.mydomain.com/test?name=DesmondMultiple Parameters
curl "http://www.mydomain.com/test?name=Desmond&age=40"Multiple Parameters with URL encoding
curl -G --data-urlencode "name=Desmond Lua" --data-urlencode "age=40" http://www.mydomain.com/testcurl POST
curl -X POST http://www.mydomain.com/testWith multiple parameters
curl --data "name=Desmond Lua&age=40" http://www.mydomain.com/testWith multiple seprated parameters
curl --data "name=Desmond Lua" --data "age=40" http://www.mydomain.com/testMultipart upload file
curl --form "[email protected]" http://www.mydomain.com/testMultipart upload file with new filename
curl --form "[email protected];filename=newname.txt" http://www.mydomain.com/testMultipart upload file with parameters
curl --form "[email protected]" --form name="Desmond Lua" --form age=40 http://www.mydomain.com/testcurl JSON
curl -X POST -d '{"name": "Desmond Lua", "age": 40}' -H "Content-Type:application/json" http://www.mydomain.com/testJSON parameters from file
curl -X POST -d @test.json -H "Content-Type: application/json" http://www.mydomain.com/testOptions
-v Verbose to observe HTTP headers
curl -v http://www.mydomain.com/test % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 65.254.242.180...
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to www.mydomain.com (65.254.242.180) port 80 (#0)
> GET /test HTTP/1.1
> Host: www.mydomain.com
> User-Agent: curl/7.47.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 301 Moved Permanently
< Location: https://www.mydomain.com/test
< Server: BigIP
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 0
<
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
* Connection #0 to host www.mydomain.com left intact-s Silient to slient the progress (% Total ... )
curl -s http://www.mydomain.com/testRemove the following
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 65.254.242.180...
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to www.mydomain.com (65.254.242.180) port 80 (#0)curl Alternatives
Refer Tools to Test REST API
References: