Igor Sobreira

Posting strings using HTTPie

Some time ago I came across this great command line tool to make http requests: HTTPie. Simple and intuitive API:

http PUT example.org X-API-Token:123 name=Igor

this sends that PUT as JSON. To submit as form (application/x-www-form-urlencoded; charset=utf-8), just set the -f flag.

Now it took me some time to figure out how to send a raw string as body. It turns out you can just write to it's stdin:

echo '{"name":"Igor"}' | http PUT example.org

Nice API.

blog comments powered by Disqus

My name is Igor Sobreira and is my website. I'm a software developer working at Real Geeks. I currently live in Hawaii doing the two things that I like most: windsurfing and writing software.

See more about me and get in touch.