title: Post JSON HttpContent to ASP.NET Web API
body: <p>I have an ASP.NET Web API hosted and can access http get requests just fine, I now need to pass a couple of parameters to a PostAsync request like so:</p>
  
  <pre><code>var param = Newtonsoft.Json.JsonConvert.SerializeObject(new { id=_id, code = _code });
  HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json");
  
  var response = client.PostAsync(string.Format("api/inventory/getinventorybylocationidandcode"), contentPost).Result;
  </code></pre>
  
  <p>This call is returning a 404 Not Found result. </p>
  
  <p>The server side API action looks like so:</p>
  
  <pre><code>[HttpPost]
  public List&lt;ItemInLocationModel&gt; GetInventoryByLocationIDAndCode(int id, string code) {
  ...
  }
  </code></pre>
  
  <p>And just to confirm my route on the Web API looks like this:</p>
  
  <pre><code>config.Routes.MapHttpRoute(
              name: "DefaultApiWithAction",
              routeTemplate: "api/{controller}/{action}/{id}",
              defaults: new { id = RouteParameter.Optional }
  );
  </code></pre>
  
  <p>I assume I'm passing the JSON HttpContent across incorrectly, why would this be returning status 404?</p>