Skip to the text

EASYTECH ARCHIVE · AMBER-TERM 1989

$ less ~/blog/testing-webservices-circa-2013.txt

-rw-r--r-- cesar Feb 05 2013 testing-webservices-circa-2013.txt

ARCHIVED · written in 2013. Kept as it was; some of it may be out of date.

Testing webservices circa 2013

Back in 2009, our Leandro (a.k.a TatooKa) wrote an awesome post on how to use curl to do POSTs and other HTTP magic. Back then curl was the way to go when you wanted to do command line HTTP GET/POST/PUT. Nowadays there’s a simpler and more modern variation: httpie.

To install on Ubuntu just do:

$ sudo apt-get install httpie

Once installed, you can do a simple HTTP POST with form variables like so:

$ http --form POST api.myservice.com/auth/login username=guest password=secretpassword
as a response you would get something like this (a JSON response in this case):

A sample output of a Webservice returning a JSON object.
A sample output of a Webservice returning a JSON object.

As you can see the response is much cleaner: there’s color coding showing you the response headers, the body is detected to be a JSON object and its nicely formatted. To see many other cool examples go to its page on Github: https://github.com/jkbr/httpie