title: WCF POST JSON HttpWebRequest to a restful service does not work properly
body: <p>I'm trying to make a WCF POST call to a restful service but the object that I provide does not seem to be deserialized properly by the server and is set to null.</p>
  
  <p>WCF Service:</p>
  
  <pre><code>[OperationContract]
  [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat =      WebMessageFormat.Json,
  BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "BuildItems")]
  void Upgrade(BuildItem item);
  </code></pre>
  
  <p>Client code:</p>
  
  <pre><code>public void Upgrade(BuildItem item)
  {
      string uri = string.Format(@"http://localhost:9001/AFMServer" + "/BuildItems");
      var request = HttpWebRequest.Create(uri);
      request.Method = "POST";
      request.ContentType = "application/json; charset=utf-8";
      string json = JsonConvert.SerializeObject(item);
  
      using (var streamWriter = new StreamWriter(request.GetRequestStream()))
      {
          streamWriter.Write(json);
          streamWriter.Close();
      }
      request.GetResponse();
  }
  </code></pre>
  
  <p>The service gets called property server side, but the BuildItem is null.</p>
  
  <p>Any idea on what I am doing wrong?</p>
  
  <p>Thanks</p>
  
  <p>EDIT - found the problem. Since I am using "Wrapped" in need to wrap the object with the parameter name:</p>
  
  <p>{"item":{"CompletionDateTime":"/Date(-62135596800000+0000)/","Id":0,"ItemId":7,"ItemType":0}}</p>
  
  <p>HTH</p>