title: XMLHttpRequest cannot load URL. Invalid HTTP status code 400 (WebApi with angularJs on Chrome)
body: <p>I have WebApi Application and a simple consuming web client. I am sending requests to webApi using angularJS from web client. And cors is already enabled of course.</p>
  
  <p>I have had problems with Post on chrome but I fixed it using param to the object sent, I thought it would be the same for Put but I got 'XMLHttpRequest cannot load URL. Invalid HTTP status code 400' on chrome whereas it's working okay on IE.</p>
  
  <p>C# code :</p>
  
  <pre><code>public void UpdateLampe(int Id, Lampe lampe)
      {
  
          var context = new eDomDataContext();
          var found = context.Lampes.SingleOrDefault(p =&gt; p.Id == Id);
          if (found != null)
          {
              found.Etat = lampe.Etat;
              found.Date = DateTime.Now;
  
              context.Lampes.Attach(found);
              context.Entry(found).State = EntityState.Modified;
  
              context.SaveChanges();
          }
      }
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//Post request (works ok)
  
  var lampe = $.param({'TypeObject': typeObject, 'SalleId': salleId});
          $http({
            method: "POST",
            url: "http://localhost:1770/api/Lampe",
            data: lampe,
            headers: {'Content-Type': 'application/x-www-form-urlencoded',}
          }).success(function (data) {
            alert("it works");
            }).error(function () {
            console.log(Error);
            alert('Error reading JSON file.');
          })
            .then(function (response) {
                    return response;
            });
  
  
  //Put request  &lt;= still have problem
  
  var etat = $.param({'Etat' : false});
  $http({
            method: "PUT",
            url: "http://localhost:1770/api/Lampe/1" ,
            data: etat,
            headers: {'Content-Type': 'application/x-www-form-urlencoded',}
          }).success(function (data) {
            alert("it works");
            }).error(function () {
            console.log(Error);
            alert('Error reading JSON file. - ');
          })
            .then(function (response) {
                    return response;
            });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Is there anything with what I did?</p>
  
  <p>Thank you for your help.</p>