patkua@work

The intersection of technology and leadership

Category: Websites

Scripting web applications with cURL

I first used cURL on a project a few years ago whilst testing a RESTful applciation. It’s a really great tool and plenty of options to do things. I however, keep forgetting some of the simple commands you might use to interact with a RESTful, or even just a web application. This is really good if you want to test AJAX resources as well.

I’m putting the examples I’ve used the most up here for easy reference. You might even find it handy as well.

Perform a HTTP GET instead of POST

curl -G -F "formParamName=@fileToSendOnDisk.txt" http://localhost/someGetUri

Sending the contents of a file from disk as part of FORM data

curl -F "formParamName=@fileToSendOnDisk.txt" http://localhost/someUri

Note that the @ is very important here. You can use curl to give it content type as well.

curl -F "formParamName=@fileToSendOnDisk.json;type=text/json" http://localhost/someUri

Sending form post data as a single string

curl -d "param1=value1&param2=value2" http://localhost/someUri

Send some form post data and print the HTTP response code as the last row to the console

url -d "param1=value1&param2=value2" http://localhost/someUri -w "%{http_code}\n"

Post data to a HTTPs endpoint ignoring self-signed certificates

curl -d "param1=value1&param2=value2" https://localhost/someUri -k

Follow redirects, printing out response code and URL that was last fetched after posting data

curl -d "param1=value1&param2=value2" http://localhost/someUri -k -w "%{http_code}\n%{url_effective}\n" -L

Hope you find this useful although you can find a much larger manual in the man page, or on this site here.

Some Links

  • Design comics – An extremely useful website under the Creative Commons license that lets you create stories with a series of people.
  • Cayra – Free new mindmapping Software built using WPF
  • Kuler – Nice browsing for looking through different colour schemes

Argos Uses Websphere

I’m not sure what makes it difficult people putting in a DNS entry so that [somesite].com redirects to www.[somesite].com. I hit Argos yesterday only to find out that apparently they use Websphere. That’s all very nice to know as a techie, but as a customer, it’s not quite the user experience I want.

Argos and Websphere

© 2017 patkua@work

Theme by Anders NorenUp ↑