Use wget and curl with headers
Use wget and curl with headers
Sending custom headers is something I do constantly — auth tokens, content type, API keys. Both wget and curl support it but the syntax is different. The POST with a data file option is particularly useful when testing XML or JSON APIs from the command line.
- wget request with headers
–no-check-certificate : to ignore SSL validation errors (use with caution)
-O : to print output on console
1
$ wget --no-check-certificate -O - "https://www.site.com/bla/bla" --header="accept: application/json" --header="authToken: bla_bla_token"
- curl request with headers
–insecure : to ignore SSL validation errors (use with caution)
1
$ curl --insecure -H "accept: application/json" -H "authToken: bla_bla_token" https://www.site.com/bla/bla
- curl POST request with headers and data file to be posted
–insecure : to ignore SSL validation errors (use with caution)
–data @: add file name after @ that will contain the request to be sent
1
$ curl --insecure -H "Content-Type:application/xml" -X POST https://blabla.com --data @file_name.txt
This post is licensed under
CC BY 4.0
by the author.