Use Fiddler with Basic Authentication to access RESTful WebAPI

brianhevans picture brianhevans · Sep 19, 2012 · Viewed 88.4k times · Source

I have a WebAPI that works without issue. I have tested locally and deployed to my server and configured this service in IIS to use Basic Authentication. I am able to browse to my service and I receive the Authentication challenge I expect and all works swimmingly! Now I want to use Fiddler to test this and I have constructed a POST to a specific url and I got a 401 (Unauthorized) error. So I decided to add a base64 string in my Request Header and I am now getting a 500 error.

What I would like to know is, does my Request Header look correct? I am obviously going to obfuscate my Host and base64 string which contains the format username:password for the Authentication challenge.

User-Agent: Fiddler
Host: xxx.xxx.xxx.xxx:xxxx
Content-Length: 185
Content-Type: text/json
Authorization: Basic jskadjfhlksadjhdflkjhiu9813ryiu34

Answer

AlexGad picture AlexGad · Sep 19, 2012

Fiddler has a tool that does the Base64 for you. Just create your string: username:password and then go to Tools -> TextWizard and enter the username password combo and choose ToBase64. Copy and paste that into your Authorization header and you should be good to go.