title: How do you debug a POST request that is running on an in memory server?
body: <p>So I'm trying to test my API using an in memory Http Server, as advised by this blog post: <a href="http://blogs.msdn.com/b/youssefm/archive/2013/01/28/writing-tests-for-an-asp-net-webapi-service.aspx" rel="nofollow">http://blogs.msdn.com/b/youssefm/archive/2013/01/28/writing-tests-for-an-asp-net-webapi-service.aspx</a></p>
  
  <p>My code looks like this: </p>
  
  <pre><code>[TestMethod]
      public void AddNewCustomer()
      {
          config = new HttpConfiguration();
          WebApiConfig.Register(config);
          HttpServer server = new HttpServer(config);
          using (HttpMessageInvoker client = new HttpMessageInvoker(server))
          {
              using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Customer"))
  
              {
                  request.Content = new StringContent(@"{ ""Email"" : ""me@you.com"", ""Password"" : ""password"" }");
                  request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                  using (HttpResponseMessage response = client.SendAsync(request, CancellationToken.None).Result)
                  {
                      Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
                  }
              }
          };
      }
  </code></pre>
  
  <p>I've tried testing the actual API, which works, when I post a customer it responds correctly. When I try testing it with this, the response.StatusCode is 'internal server error'.</p>
  
  <p>That's irritating, but what's more confusing is that I find myself unable to debug what's actually going wrong - I don't know why it's getting this error in this environment, and I can't stick break points in to test what's happening.</p>
  
  <p>EDIT: My response body is just:</p>
  
  <pre><code>        "{\"Message\":\"An error has occurred.\"}"
  </code></pre>
  
  <p>Any ideas?</p>