Using curl from the shell/command prompt (ouch) is a great way to test API’s, retrieve files from FTP servers etc etc. Maybe your building an application that consumes an API or maybe your using scripts to perform remote functions. Knowing how to use and test things at this level can often provide that piece of insight that you need when debugging, planning or building solutions.

Prerequisite: have the curl binary installed!

HTTP VERB’s – Use -X and take your pick from the CRUD: curl -X PUT hostname:port/some/uri
Basic Authentication: curl -u username:password hostname:port/some/uri
Query String Params: curl -d “filter=curl_rules” hostname:port/some/uri (you can more -d switches if you need to add more QS params)
Save a webpage: curl -o index.html
Save a file from an FTP server: curl
Post a file to a server: curl –data @file.txt hostname:port/some/uri
Define the content Type: curl -H “Content-Type:text/json” –data @file.txt hostname:port/some/uri






Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>