-i or –include | Include HTTP Header Information with data curl -i https://www.google.com |
-I or –head | Only HTTP Header Information and no data curl -I https://www.google.com |
-H | Send headers in request curl -H “Accept:application/json” https://jsonplaceholder.typicode.com/posts/1 |
-o or –output | Download the data into a file using -o command Command : curl -o hello.html www.google.com |
-O | Download the entier data as it is in the current folder Command : curl -O https://jsonplaceholder.typicode.com/posts |
-u | Authenticate using user id and password in curl curl -u username:password http://demo.website.com |
-L | Follow url redirection example (https://google.com is redirected to https://www.google.com) but curl won’t re direct it automatically to that, to do that you have to fire -L command with that Demo : curl https://google.com Actual Command : curl -L https://google.com |
-k or –insecure | allow to connect to SSL sites without certificates, Connect HTTPS/SSL URL and ignore any SSL certificate error -k should always be applied on https URL else the URL will not have any affect |
-v or –verbose | Gives detailed information about the client server interaction. curl –verbose https://jsonplaceholder.typicode.com/posts/3 |
–trace | Gives detailed information about the client server interaction in a file curl –trace trace.txt https://jsonplaceholder.typicode.com/posts/3 curl –trace-ascii trace-ascii.txt https://jsonplaceholder.typicode.com/posts/3 |
FTP Upload and download using CURL
Upload Command (Uploads logo.svg in the current folder to ftp server)
curl -u username@heapwizard.com:password -T logo.svg ftp://ftp.heapwizard.com
Download Command (Downloads ftp.heapwizard.com/logo.svg to the current folder)
curl -u username@heapwizard.com:password -O ftp://ftp.heapwizard.com/logo.svg
WINSCP like Upload and download using CURL
Rest API using CURL command
Note : Response of your URL is dependent on the server you send response to, it is not necessary that it will always send a response
Post data using CURL command using -d or –data attribute or curl
curl -X POST -d "title=Hello&body=HelloWorld" https://jsonplaceholder.typicode.com/posts
Update data using CURL command using -X PUT method
curl -X PUT -d "title=Hello&body=World" https://jsonplaceholder.typicode.com/posts/3
Delete data using CURL command using DELETE method
curl -X DELETE https://jsonplaceholder.typicode.com/posts/3
Post a json data to an URL using CURL
curl -X POST -H "Accept:application/json" https://jsonplaceholder.typicode.com/posts -d '{title:Hello,body:HelloBody}' curl -X POST -H "Accept:application/json" https://reqres.in/api/users -d '{"name": "morpheus","job": "leader"}'
Use proxy to connect to URL in CURL
curl --proxy yourproxy:port http://yoururl.com
There is noticeably a bundle to learn about this. I assume you made sure nice points in features also.