title: MVC 4 Web Api Post
body: <p>I want to make an insertion from a distant client for that I need to send data via http.<br>
  I can use the <code>getPerformances()</code> correctly with an <code>httpClient</code> <code>api/performances?date={0}</code></p>
  
  <p>I want to ask if my <code>postPorformances()</code> implemntation inside my <code>PerformancesController</code> is corrrect and if it is how to call it from a client?</p>
  
  <p>Here is my implementation:</p>
  
  
  
  <pre><code>public class PerformancesController : ApiController
      {
          // GET api/performances
          public IEnumerable&lt;Performance&gt; getPerformances(DateTime date)
          {
              return DataProvider.Instance.getPerformances(date);
          }
  
          public HttpResponseMessage postPerformances(Performance p)
          {
              DataProvider.Instance.insertPerformance(p);
              var response = Request.CreateResponse&lt;Performance&gt;(HttpStatusCode.Created, p);
              return response;
          }
      }
  </code></pre>
  
  
  
  <pre><code>public class Performance {
      public int Id {get;set;}
      public DateTime Date {get;set;}
      public decimal Value {get;set;}
  }
  </code></pre>
  
  <p>I have tried this one but I'm note sure:</p>
  
  <pre class="lang-c# prettyprint-override"><code>  private readonly HttpClient _client;
    string request = String.Format("api/performances");
    var jsonString = "{\"Date\":" + p.Date + ",\"Value\":" + p.Value + "}";
    var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
    var message = await _client.PutAsync(request, httpContent);
  </code></pre>