title: Web Api 2 bad request
body: <p>Im a beginner with Web api and Im trying to setup a simple owin selfhosted service that Im trying out. </p>
  
  <p>I've been searching stackoverflow and other places for a while now, but I cant seem to find anything obviously wrong. </p>
  
  <p>The problem I have is that I get a bad request response everytime I try to call my service.</p>
  
  <p>The controller looks like this:</p>
  
  <pre><code> [RoutePrefix("api/ndtdocument")]
  public class NDTDocumentsController : ApiController, INDTDocumentsController
  {
      [HttpGet]
      public IHttpActionResult Get()
      {
          var document = Program.NDTServerSession.GetNextNDTDocument(DateTime.Today);
          if (document == null)
              return null;
  
          return Ok(document);
  
  
      }
  
      [Route("")]
  
      public IHttpActionResult Post([FromBody] NDTDocument ndtDocument)
      {
          try
          {
              Program.NDTServerSession.AddNDTDocument(ndtDocument);
              return Ok();
          }
          catch(Exception ex)
          {
              return BadRequest(ex.Message);
  
          }
  
  
      }
  
  
  
  
  
  }
  </code></pre>
  
  <p>And the client looks like this:</p>
  
  <pre><code>     static void Main(string[] args)
      {
  
  
           AddNDTDocument(@"C:\Testing.txt");
  
  
      }
  
  
  
      private static void AddNDTDocument(string centralserverPath)
      {
  
          var client = GetServerClient();
          NDTDocument document = new NDTDocument();
          var response = client.PostAsJsonAsync("ndtdocument", document).Result;
  
  
      }
  
      static HttpClient GetServerClient()
      {
          var client = new HttpClient();
          client.BaseAddress = new Uri("http://localhost:9000/api/");
          client.DefaultRequestHeaders.Accept.Clear();
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
          return client;
  
  
  
      }
  </code></pre>
  
  <p>I can see when I debug it that the request uri is infact <a href="http://localhost:9000/api/ndtdocument" rel="nofollow">http://localhost:9000/api/ndtdocument</a></p>
  
  <p>But the response is allways bad request and I have a breakpoint in the controller and it is never invoked. </p>
  
  <p>Everytime I try to do something with web apis I Always run into some weird (but simple problem).</p>
  
  <p>Any thoughts?</p>
  
  <p>Thanks!</p>