What is curl?
curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.
If you don't have curl installed you can install it by following below steps.
Install curl on Windows:
Download curl package from Curl Offical Site , now unzip it wherever you want. No need to install it.
Setup Curl in Windows:
You'll have to give path to curl.exe in your Environment variables if you want to use it from anywhere in the command line. To do this, pick any nice location you want and add it to the system path, like this:
- Click the Windows 10 start menu at bottom left, and start typing 'environment'
- You'll see this menu item "Edit the System Environment Variables", select it
- A System Properties window will open up. You will see a button "Environment Variables" just click it
- Then select the path variable, and click the Edit button
- Click the Add button, paste in the folder path where you have unzipped the curl package or where curl.exe resides
- Click Ok as needed. Close all the open command prompt windows and reopen it, so they get the new path location for curl
Now enjoy typing curl at any command prompt in Windows
To send Header data like "Accept: application/json" or "Content-Type: application/json" from curl you can use below commands
Send a Header data through HTTP Request using curl
Examples
curl --header "X-MyHeader: 123" www.google.com
curl -i -H "Accept: application/json" -H "Content-Type: application/json" http://hostname/resource
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET http://hostname/resource