Scott Hanselman

Installing HTTPIE (HTTP for Humans) on Windows - Great for ASP.NET Web API and RESTful JSON services

August 17, '12 Comments [38] Posted in ASP.NET | Open Source | Web Services
Sponsored By

Recently in on a post on the RESTful ASP.NET Web API framework I used curl to post JSON to an HTTP endpoint:

curl -X POST -H "Content-Type: application/json" -d "{ Name: 'Scott Guthrie', Age: 67}"

Curl is lovely and should be in your c:\utils folder and more importantly in your PATH. I have a UTILS folder in my Dropbox and in the PATH on all my machines. Whenever I find a useful no-install utility I put it in there.

Curl is great but it's still confusing enough to me that I don't use it enough. It's slightly obscure command-line switches are keeping me from using it on a regular basis.

For HTTP work there is a better utility called HTTPie at (It has nothing to do with IE (Internet Explorer)). For Mac and Linux folks who use Python all the time, it's easy to install, you just

pip install -U httpie

For Windows folks who don't use Python it's a little harder to install, but it's worth it and I recommend you take a moment and set it up. You'll wonder how you lived without it.

Installation of HTTPIE

First, go download Python. I got the x86 version of Python 3.2.3 cause it was the latest and I didn't think I needed the x64 one.

I then added c:\python32 and c:\python32\scripts to my path. I do this by hitting WinKey+Break, then Advanced, then Environment.

Add Python and Python/Scripts to your PATH

Second, download CURL. Yes, I realize the irony, but it's still a VERY useful tool. I downloaded the 7.27 binary SSL Win32 version, unblocked it, unzipped it and put it in C:\UTILS so it was automatically in my PATH.

Third, run this from an Administrator command prompt. Note again that it needs both curl.exe and python.exe in the PATH to run as it is. This should run without incident.

curl | python

Then run

curl -k | python

This should end with "successfully installed pip."

Pip is a Python package manager.

Finally, run

pip install -U

I'm recommending you install the development edge build of HTTPie rather than just "pip install httpie" as the developer is actively fixing Windows issues and just recently helped me with one.

So, to sum up what you need to run, in four lines, assuming curl.exe, python.exe and python scripts are all in your PATH.

curl | python
curl -k | python
curl | python
pip install -U

Running HTTPie

You'll know it works if you can run "http" from the command line and get this output:

C:\Users\scottha\Desktop> http
usage: [--help] [--version] [--json | --form] [--output FILE]
[--pretty | --colors | --format | --ugly]
[--print OUTPUT_OPTIONS | --verbose | --headers | --body]
[--style STYLE] [--stream] [--check-status]
[--auth USER:PASS] [--auth-type {basic,digest}]
[--verify VERIFY] [--proxy PROXY] [--allow-redirects]
[--timeout SECONDS] [--traceback] [--debug]
[METHOD] URL [ITEM [ITEM ...]] error: too few arguments

Here's where the fun happens. The syntax is VERY intuitive. Here I post some JSON to an endpoint that will echo it back.

C:\> http POST http://localhost:50231/api/Contact name=scott age:=100
HTTP/1.1 200 OK
Content-Length: 26
Content-Type: application/json; charset=utf-8
Date: Fri, 17 Aug 2012 21:59:51 GMT
Server: Microsoft-HTTPAPI/2.0

"age": 100,
"name": "scott"

It's just like using HTTP itself, except from the command line. The best part is that it will take name=value for strings and name:=value for non-strings and turn it into JSON!

HTTPie supports any HTTP Verb, FORM data, raw JSON, and lots of other features. Here's another example:

C:\>http PUT name=John age:=29 married:=false hobbies:='["http", "pies"]'
PUT /person/1 HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
User-Agent: HTTPie/0.2.7dev

"age": 29,
"hobbies": [
"married": false,
"name": "John"

There's lots more examples here and I encourage you to check it out. I'll leave you with a lovely PowerShell screenshot showing that HTTPie also does syntax highlighting at the command line!

HTTPie is HTTP for Humans and Syntax Highlights as well

Awesome. Expect to see this tool in all my Web API and JSON demos. Go get it and star it at GitHub.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Friday, 17 August 2012 22:52:07 UTC
That's pretty cool. Now do it in PowerShell so that it returns a rich object with metadata and json response.
Friday, 17 August 2012 22:57:54 UTC
Hey, this looks like a great tool and a great tutorial on setting up cUrl, Python via command line. But why not set the environment path variables via the command line as well? Here's some ways to do it:
Friday, 17 August 2012 23:14:48 UTC
Scott, doesn't Python on Windows come with easy install baked in? If so, you can "easy_install pip" to get pip. You can also probably "easy_install httpie" directly (but not the dev edge version).
Friday, 17 August 2012 23:36:09 UTC
I'm playing with building a PowerShell version :)
Saturday, 18 August 2012 00:04:06 UTC
Check out Fiddler's Composer tab for similar functionality. It doesn't have the cool pseudo-JSON syntax, but I find that copy-paste-modify from previous responses is quite easy and reduces errors.

John Peterson puts this technique to great use in his aspConf Intro to Web API session. Specifically, check out 40:25-43:00 where he GETs a resource, copies the JSON response, tweaks it and PUTs it, and then GETs it to show that the changes worked. Earlier in the session (32:20-34:20) he also shows tweaking the Content-Type header to toggle between XML, JSON, or whatever.

Anyway, while HTTPIE looks pretty cool, I think Fiddler's Composer demos better, will encounter lower Microsoft cultural resistance, and is nicely integrated into other Fiddler features you already know and love.
Saturday, 18 August 2012 00:14:18 UTC
Whoops, I see you're already familiar with using Fiddler's Composer to post JSON here! Regardless, I hope this helps someone discover another one of Fiddler's under-utilized cool features.
Saturday, 18 August 2012 00:26:39 UTC
Haha, and then I just now watched your 6-minute ASP.NET Web API video and you used Fiddler's Composer to do the exact same things as John Peterson (Accept/Content-Type and reposting modified JSON), but in a more compressed "Hanselminutes" manner! Awesome! I recommend folks check it out, from 3:30 until the end.
Saturday, 18 August 2012 01:33:30 UTC
Steve - easy_install is on the way out and pip is recommended going forward so I thought I'd encourage folks to use the right stuff.

Mike - I wanted people to add it to the SYSTEM environment and not just their PowerShell profile.
Saturday, 18 August 2012 07:09:35 UTC
I you're using Chrome, there's a pretty good plugin/app/thing from Play Store (no idea what the correct nomenclature is) called Advanced REST Client that let's you do similar stuff.

It's not got the chic appeal of command line but is useful if you tend to do your debugging in Chrome.
Saturday, 18 August 2012 17:14:31 UTC
I used the Cygwin installer to get curl and python. This tool is awesome. Thanks for sharing!
Saturday, 18 August 2012 17:48:27 UTC
Now with the Invoke-WebRequest, and Invoke-RestMethod in PS v.3 we will be able to replicate most of curls functionality. Get busy Doug Finke, : )
Sunday, 19 August 2012 02:29:53 UTC
Scott, my point was to use "easy_install" to get pip. It seems like the easiest way.
Sunday, 19 August 2012 09:33:06 UTC
What else is in your C:\utils, Scott?
Sunday, 19 August 2012 13:56:55 UTC
Install Pscx to get...

Add-PathVariable C:\Python27 -Target Machine -Target Process

...along with many other goodies.

Personally, I just went through a fresh install of Windows 8 and had to update everything, and I do all this from the commandline. I don't use curl anymore, since
(New-Object Net.WebClient).DownloadString("") | python
does the same thing.
Monday, 20 August 2012 07:12:14 UTC
We use webforms. We're pretty much stuffed for either curl or httpie correct? (At least with respect to put/post requests).

Trying to automate a smoke test has lead me to driving IE via automation (selenium), which is pretty painful.
Monday, 20 August 2012 13:47:29 UTC
Yes, pip is in the process of replacing easy_install, but the accepted way to bootstrap pip is still to easy_install pip (then never use easy_install again).

Another good alternative on Windows would be to use Chocalatey:

Certainly the combined installation of both Chocalatey and then pip from the command line is a shorter, subtler two line dance:

C:\> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString(''))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
C:\> cinst pip

Note that the cinst pip would also install Python as needed.

(Also, I still find it fascinating the way Chocalatey uses powershell as its CURL and script engine all in one CMD command line.)
Monday, 20 August 2012 14:37:22 UTC
Installed pip using Chocolatey (I recommend this method)

Installed HTTPie using pip

This is awesome. Scott, thanks for the tip.
Monday, 20 August 2012 16:31:19 UTC
@Josh - Yeah, I'm suffering the same issues - it looked like the "session" option might work, but no luck with forms-based authentication. Or at least I couldn't get --session to work with --form POST. If someone does know of a way, that'd be awesome....
Monday, 20 August 2012 19:55:15 UTC
Can you please post a list of all of the tools in your C:\Utils folder? We're all very interested!
Monday, 20 August 2012 20:03:09 UTC
Any suggestions on how to get this to work behind an NTLM proxy? I was able to get curl to work, by setting a proxy in the environment setting and passing my username and password. However, running the python script failed at create connection since the proxy server refused it.
Tuesday, 21 August 2012 11:39:38 UTC
Another great alternative for editing your Env Vars is a free Rapid Environment Editor at I sure have that in my c:\utils.
Wednesday, 22 August 2012 01:07:42 UTC
Hey Scott,

Your Curl link seems a bit off.

Wednesday, 22 August 2012 11:34:32 UTC
You can also just, you know, use a browser to download and :) (just dump those links into an address bar). Didn't know easy_install will install pip, though, that will save me some time in the future!
Thursday, 23 August 2012 05:08:01 UTC
Scott Frost, start here:
Thursday, 23 August 2012 06:53:02 UTC
I do prefer to use Poster, which is a Firefox plugin and makes creating HTTP request easy. Fiddler also rocks.
Thursday, 23 August 2012 07:24:17 UTC
OK, no install one-liners that work on a fresh windows install:

set PATH=%PATH%;<python-dir>;<python-dir>\Scripts
python -c "from urllib.request import urlopen;exec(urlopen('').read())"
easy_install pip
pip install -U
Thursday, 23 August 2012 19:41:48 UTC
I prefer Postman for Chrome. I like it much better than trying to write JSON on a command line.
Friday, 24 August 2012 12:40:42 UTC
Hi Scott,

This is a really great article! That is all. :)
Saturday, 25 August 2012 06:29:05 UTC
I dont want to install python on my machine - as this is so Un-Windows :-)
But I also would like to use that tool.
Therefore I started a .net port of this tool on github
Tuesday, 28 August 2012 10:39:19 UTC
Nice post Sir.

BTW, I believe that it should have been C:\Python32\Tools\Scripts instead of C:\Python32\Scripts.
Tuesday, 28 August 2012 10:43:38 UTC
Ah, sorry. You were right. I should stay the same as C:\Python32\Scripts. I realized that after installing pip.
Thursday, 27 September 2012 15:42:02 UTC
@Robert I managed to get this working behind our proxy, as detailed below. I don't whether this approach can be easily adapted to cover your particular case, but even if not it may be of some use to others.

To start with, I downloaded the first python script using
curl -x [proxy ip] >

and added the following lines to the beginning of the download_setuptools() method before running the script using python

import urllib.request as req
proxyip = ''
proxy = req.ProxyHandler({'http': proxyip)
opener = req.build_opener(proxy, req.HTTPHandler)

I then downloaded the second script using
curl -x [proxy ip] -k >
and similarly inserted the same lines above to the beginning of the unpack() method at the end of the script. Running the modified script using python successfully installed pip.

Finally, I provided the --proxy parameter to pip to successfully complete the install of httpie:

pip install --proxy [proxyip:proxyport] -U
Henry Buckley
Saturday, 06 October 2012 20:48:07 UTC
Thanks for the great article.

I've been using Chrome's Advanced Web Client with much success but I find it's lacking a good request library to organise those large numbers of sample HTTP requests what are a typical by-product of a RESTful based dev project. HTTPIE gives me much more flexibilty in this regard.

By the way, the Pip installation failed to work for me using Python 3.X (Windows 8). Not to worry as I sailed through it after a quick install of Python 2.2.7. I would recommend this well written tutorial for those who run into similar installation difficulties.
Finbar Leahy
Thursday, 29 November 2012 19:04:55 UTC
Anyone get this working through a proxy? All web request fire me a 407.
Monday, 03 December 2012 02:25:12 UTC
Scott, I still cant get why are you using curl if you have fiddeler installed?
Monday, 17 December 2012 17:35:08 UTC

How did you get the highlighting to work in your powershell console? When I run *http* in a PW console, I see ASCII gibberish like below:

PS C:\> http GET --style=fruity
←[34mHTTP←[39;49;00m/←[39;49;00m←[34m1.1←[39;49;00m ←[39;49;00m←[34m200←[39;49;00m ←[39;49;00m←[36mOK←[39;49;00m
←[36mCache-Control←[39;49;00m:←[39;49;00m ←[39;49;00mno-cache←[39;49;00m
←[36mDate←[39;49;00m:←[39;49;00m ←[39;49;00mMon, 17 Dec 2012 17:29:06 GMT←[39;49;00m
←[36mPragma←[39;49;00m:←[39;49;00m ←[39;49;00mno-cache←[39;49;00m
←[36mContent-Length←[39;49;00m:←[39;49;00m ←[39;49;00m3161←[39;49;00m
←[36mContent-Type←[39;49;00m:←[39;49;00m ←[39;49;00mtext/html; charset=UTF-8←[39;49;00m
←[36mExpires←[39;49;00m:←[39;49;00m ←[39;49;00mThu, 01 Jan 1970 00:00:00 GMT←[39;49;00m
←[36mSet-Cookie←[39;49;00m:←[39;49;00m ←[39;49;00mADMINCONSOLESESSION=yQqDQPWCr7w9wn5dfdtqLfCs3Jx9J4DHT1YKvQDprYJrGx5LvB
JV!-1034303106; path=/←[39;49;00m
←[36mContent-Language←[39;49;00m:←[39;49;00m ←[39;49;00men-US←[39;49;00m
←[36mX-Powered-By←[39;49;00m:←[39;49;00m ←[39;49;00mServlet/2.5 JSP/2.1←[39;49;00m

I'm running on:

Win XP Pro Version 2002 SP3
Monday, 21 January 2013 20:19:29 UTC
for lazy people.
I used. I had to use a rest api ( and I stumbled upon this article.

My 50 cents: I used Fiddler + plugin to generate code c# form request.
Wednesday, 24 April 2013 06:21:31 UTC
Anyone from you tried portable version of python and httpie? Asking because my colleague wanted to use httpie and ended at last step (some error, don't remember). So I decided to install httpie on my computer and commit to svn so everybody in our team can use it without installation.

Didn't succeeded, because easy install writes full absolute paths to python script. One quick workaround is to remove the line with absolute path, but imo it is not bulletproof generaly.
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.