If you are getting this error after adding swagger to your API project here is the solution to avoid this error:
In App_Start go to WebApiConfig.cs and comment the following line:
config.SuppressDefaultHostAuthentication(); config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));