GET request to IIS returns Microsoft-HttpApi/2.0

Windows has an HTTP service that manages calls to IIS and other HTTP enabled services on a windows machine. Either you need to configure it to handle your calls, or, in the case of WAMP or similar non-IIS-web-server-on-windows scenarios you may just need to turn it off.

When you see “Microsoft-HttpApi/2.0” returning error, such as 400 “bad URL” or “bad header”, etc. the problem is most likely because the HTTP.sys service is intercepting your http request and terminating it because it does not meet with the minimum validation rules that are configured.

This configuration is found in the registry at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters. In my case, it was choking because I had a RESTful call that had a 400 character segment in the url which was 160 characters more than the default value of 260, so I

  1. added the registry parameter UrlSegmentMaxLength with a DWORD value of 512,
  2. stopped the service using net stop http
  3. started the service using net start http

I’ve run into these issues before and it is easy to troubleshoot but there is very little on the web that addresses it.

Try these links

Leave a Comment