title: ASP.NET Web API - POST/PUT/DELETE Request from an ASP.NET MVC 4 app
body: <p>I have an ASP.NET Web API REST that handles the data requests from an ASP.NET MVC 4 application</p>
  
  <pre><code>namespace CandidateAPI.Controllers
  {
    public class CustomerDetailController : ApiController
    {
  
      private static readonly CustomerDetailRepository Repository = new CustomerDetailRepository();
  
      public IEnumerable&lt;CustomerDetail&gt; GetAllCustomerDetails()
      {
          return Repository.GetAll();
      }
  
      public CustomerDetail GetCustomerDetailById(int id)
      {
          return Repository.Get(id);
      }
  
  
      public HttpResponseMessage PostCustomerDetail(CustomerDetail item)
      {
          item = Repository.Add(item);
          var response = Request.CreateResponse&lt;CustomerDetail&gt;(HttpStatusCode.Created, item);
  
          var uri = Url.Link("DefaultApi", new { id = item.ID });
          if (uri != null) response.Headers.Location = new Uri(uri);
          return response;
      }
    }
  </code></pre>
  
  <p>}</p>
  
  <p>Now in the ASP.NET MVC4 app, I have this 'wrapper' class that calls the said WEB API, This handles the GET requests</p>
  
  <pre><code> public class CustomerDetailsService : BaseService, ICustomerDetailsService
   {
      private readonly string api = BaseUri + "/customerdetail";
  
      public CustomerDetail GetCustomerDetails(int id) {
  
          string uri = api + "/getcustomerdetailbyid?id=" + id;
  
          using (var httpClient = new HttpClient())
          {
              Task&lt;String&gt; response = httpClient.GetStringAsync(uri);
              return JsonConvert.DeserializeObjectAsync&lt;CustomerDetail&gt;(response.Result).Result;
          }
      }
  }
  </code></pre>
  
  <p>Now, my problem is for the POST/PUT/DELETE REST requests</p>
  
  <pre><code> public class CustomerDetailsService : BaseService, ICustomerDetailsService
   {
      private readonly string api = BaseUri + "/customerdetail";
  
      // GET -- works perfect
      public CustomerDetail GetCustomerDetails(int id) {
  
          string uri = api + "/getcustomerdetailbyid?id=" + id;
  
          using (var httpClient = new HttpClient())
          {
              Task&lt;String&gt; response = httpClient.GetStringAsync(uri);
              return JsonConvert.DeserializeObjectAsync&lt;CustomerDetail&gt;(response.Result).Result;
          }
      }
  
      //PUT
      public void Add(CustomerDetail detail) { //need code here };
  
      //POST
      public void Save(CustomerDetail detail) { //need code here };
  
      //DELETE
      public void Delete(int id) { //need code here};
  }
  </code></pre>
  
  <p>I have tried googling this for hours now and would really appreciate if someone can point me in the right direction.</p>