How to send a Header data through HTTP Request using curl


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:

  1. Click the Windows 10 start menu at bottom left, and start typing 'environment'
  2. You'll see this menu item "Edit the System Environment Variables", select it
  3. A System Properties window will open up. You will see a button "Environment Variables" just click it
  4. Then select the path variable, and click the Edit button
  5. Click the Add button, paste in the folder path where you have unzipped the curl package or where curl.exe resides
  6. 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


curl --header "X-MyHeader: 123"
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

Solution Worked 0 UpvotesUpvote


Solution Didn't Worked 0 DownvotesDownvote



Play 2048 Game Online

Search Tags