title: How to get HttpClient Json serializer to ignore null values
body: <p>I'm currently working with a console app which I'm using the HttpClient to interact with an Apache CouchDB database. I'm using this article: <a href="http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client" rel="noreferrer">http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client</a></p>
  
  <p>I'd like to ignore the null properties in my class when I'm serializing and sending a document to my database via the PostAsJsonSync but I'm not sure how:</p>
  
  <pre><code>public static HttpResponseMessage InsertDocument(object doc, string name, string db)
      {
        HttpResponseMessage result;
        if (String.IsNullOrWhiteSpace(name)) result = clientSetup().PostAsJsonAsync(db, doc).Result;
        else result = clientSetup().PutAsJsonAsync(db + String.Format("/{0}", name), doc).Result;
        return result;
      }
  
      static HttpClient clientSetup()
      {
        HttpClientHandler handler = new HttpClientHandler();
        handler.Credentials = new NetworkCredential("**************", "**************");
        HttpClient client = new HttpClient(handler);
        client.BaseAddress = new Uri("*********************");
        //needed as otherwise returns plain text
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        return client;
      }
  </code></pre>
  
  <p>Here's the class I'm serializing....</p>
  
  <pre><code>class TestDocument
    {
      public string Schema { get; set; }
      public long Timestamp { get; set; }
      public int Count { get; set; }
      public string _rev { get; set; }
      public string _id { get; set; } - would like this to be ignored if null
    }
  </code></pre>
  
  <p>Any help much appreciated.</p>