I’ve been using cURL but always had a feeling not to its potential basically because the cURL man page [WayBack] is both massive and lacks concrete useful practical examples.

For instance, I knew about the --header and --verbose options (I always use verbose names even though shorter -H and -v exist) to pass a specific header and get verbose output, but the man page basic examples like this by Tader:

There are some more examples at bropages.org/curl but they’re hardly organised or documented.

So I was really glad I found the below answer [WayBack] by Amith Koujalgi to web services – HTTP POST and GET using cURL in Linux – Stack Overflow.

But first note that recent versions (around 7.22 or higher) of cURL now need to combine the --silent and --show-error (or in short -sS ) parameters to suppress progress but show errors: linux – How do I get cURL to not show the progress bar? – Stack Overflow [WayBack]

Back to the examples

web services – HTTP POST and GET using cURL in Linux – Stack Overflow has these covered:

Request types ( --request aka -X ): GET of XML (with --header ). JSON (with --include and --header ). POST of parameters and @file content using --data aka -d . form with file upload using --form (and again @file content). logging in using --location aka -L 30x redirect following and header saving/loading using --dump-header aka -D and --cookie aka -b .

aka ): Saving output to a file using the >> redirect or --output aka -o (you might want to consider using --remote-name aka -O here).

redirect or aka (you might want to consider using aka here). Tips for pretty printing JSON using npm installing the nodejs package json . pip for python installing the pjson package. gem for ruby installing the colorful_json gem. linux using the yajl-tools package. XML using linux using the libxml2-utils package linux using the tidy package.



–jeroen

PS: Just discovered someone wrote a Unicode compatible Delphi wrapper for some of the libcurl [WayBack] functionality.