Internal server error in an ASP.NET Web API in-memory test
The exception is in Response.Content
if (Response != null && Response.IsSuccessStatusCode == false)
{
var result = Response.Content.ReadAsStringAsync().Result;
Console.Out.WriteLine("Http operation unsuccessful");
Console.Out.WriteLine(string.Format("Status: '{0}'", Response.StatusCode));
Console.Out.WriteLine(string.Format("Reason: '{0}'", Response.ReasonPhrase));
Console.Out.WriteLine(result);
}
You need to add a route so that it looks something like this:
var config = new HttpConfiguration()
{
IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always
};
config.Routes.MapHttpRoute(
name: "default",
routeTemplate: "api/{controller}/{id}",
defaults: new { controller = "Home", id = RouteParameter.Optional });
var server = new HttpServer(config);
var client = new HttpClient(server);
HttpResponseMessage response = client.GetAsync("http://somedomain/api/product").Result;
Btw, in the latest bits you get a 404 Not Found as you would expect.
Henrik