I cannot reproduce the problem you are describing.
Model:
public class Contact { public int Id { get; set; } public string Name { get; set; } public string Phone { get; set; } public string Email { get; set; } public DateTime LastModified { get; set; } }
Controller:
public class ContactsController : ApiController { public Contact Put(int id, Contact contact) { return contact; } }
Client:
class Program { static void Main() { using (var client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "application/json"; var data = Encoding.UTF8.GetBytes(@"{""Id"":3,""Name"":""mmm"",""Phone"":""000 000 0000"",""Email"":"" mmm@gmail.com "",""LastModified"":""2012-03-08T23:42:13.8681395+08:00""}"); var result = client.UploadData("http://localhost:1405/api/contacts/4", "PUT", data); Console.WriteLine(Encoding.UTF8.GetString(result)); } } }
When I start the client, the following request is sent:
PUT /api/contacts/4 HTTP/1.1 Content-Type: application/json Host: localhost:1405 Content-Length: 119 Expect: 100-continue Connection: Keep-Alive {"Id":3,"Name":"mmm","Phone":"000 000 0000","Email":" mmm@gmail.com ","LastModified":"2012-03-08T23:42:13.8681395+08:00"}
and I get the correct result from the server. Therefore, I assume that the request you are showing is not the actual request that is sent to the server.
source share