title: 400 Bad Request for OData
body: <p>I created a .NET 4.5 Web project using Visual Studio 2012 to test out using OData following <a href="http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint" rel="nofollow">this tutorial</a>.  However, whenever I send the following request from Fiddler:</p>
  
  <pre><code>PUT http://localhost:14116/odata/Products(5) HTTP/1.1
  Host: localhost:14116
  Accept: application/json
  Content-Type: application/json
  Content-Length: 67
  
  { "Name" : "Apple //e", "Price" : "1298", "Category" : "Computer" }
  </code></pre>
  
  <p>I get the following response:</p>
  
  <pre><code>HTTP/1.1 400 Bad Request
  Cache-Control: no-cache
  Pragma: no-cache
  Expires: -1
  Server: Microsoft-IIS/8.0
  X-AspNet-Version: 4.0.30319
  X-SourceFiles: =?UTF-8?B?YzpcdXNlcnNcZGxhdmVsbGVcZG9jdW1lbnRzXHZpc3VhbCBzdHVkaW8gMjAxMlxQcm9qZWN0c1xP    RGF0YVRlc3QzXE9EYXRhVGVzdDNcb2RhdGFcUHJvZHVjdHMoNSk=?=
  X-Powered-By: ASP.NET
  Date: Wed, 01 Apr 2015 14:37:41 GMT
  Content-Length: 0
  </code></pre>
  
  <p>What am I missing?  (Stack overflow is removing two empty lines in the HTTP response.)</p>
  
  <p>This request works fine:</p>
  
  <pre><code>GET http://localhost:14116/odata/Products?$filter=Price+lt+500 HTTP/1.1
  Host: localhost:14116
  Accept: application/json
  </code></pre>
  
  <p>Here's my controller: </p>
  
  <pre><code>public class ProductsController : ODataController
  {
      static List&lt;Product&gt; s_products;
      static ProductsController()
      {
          s_products = new List&lt;Product&gt;();
          s_products.Add(
              new Product
              {
                  Id = 1
                , Name = "Nexus 7"
                , Price = 179
                , Category = "Tablet"
              }
          );
      }
  
      // GET odata/Products
      [Queryable]
      public IQueryable&lt;Product&gt; GetProducts()
      {
          return s_products.AsQueryable();
      }
  
      // GET odata/Products(5)
      [Queryable]
      public SingleResult&lt;Product&gt; GetProduct([FromODataUri] int key)
      {
          return SingleResult.Create(s_products.AsQueryable().Where(product =&gt; product.Id == key));
      }
  
      // PUT odata/Products(5)
      public IHttpActionResult Put([FromODataUri] int key, Product product)
      {
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
  
          if (key != product.Id)
          {
              return BadRequest();
          }
  
          var previous = s_products.SingleOrDefault(p =&gt; p.Id == key);
          if (previous == null)
          {
              return NotFound();
          }
  
          previous.Category = product.Category;
          previous.Name = product.Name;
          previous.Price = product.Price;
  
          return Updated(product);
      }
  
      // POST odata/Products
      public IHttpActionResult Post(Product product)
      {
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
  
          s_products.Add(product);
  
          return Created(product);
      }
  
      // PATCH odata/Products(5)
      [AcceptVerbs("PATCH", "MERGE")]
      public IHttpActionResult Patch([FromODataUri] int key, Delta&lt;Product&gt; patch)
      {
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
  
          Product product = s_products.SingleOrDefault(p =&gt; p.Id == key);
          if (product == null)
          {
              return NotFound();
          }
          patch.Patch(product);
  
          return Updated(product);
      }
  
      // DELETE odata/Products(5)
      public IHttpActionResult Delete([FromODataUri] int key)
      {
          Product product = s_products.SingleOrDefault(p =&gt; p.Id == key);
          if (product == null)
          {
              return NotFound();
          }
  
          s_products.Remove(product);
  
          return StatusCode(HttpStatusCode.NoContent);
      }
  
      protected override void Dispose(bool disposing)
      {
          base.Dispose(disposing);
      }
  }
  </code></pre>