title: How to rewrite HttpRequestMessage call to support <T>
body: <p>I found a useful class that makes Web API calls with JSON serialize/deserialize support of type T. You can view the entire class/article <a href="http://johnnycode.com/2012/02/23/consuming-your-own-asp-net-web-api-rest-service/" rel="nofollow">here</a>. I think I could get a lot of use out of this class and would like to try it. There is one error left that I can't figure out how to handle. It's in the following routine:</p>
  
  <pre><code>protected HttpRequestMessage GetHttpRequestMessage&lt;T&gt;(T data)
  {
      MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/json");
      JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
      jsonSerializerSettings.Converters.Add(new IsoDateTimeConverter());
  
      JsonNetFormatter jsonFormatter = new JsonNetFormatter(jsonSerializerSettings);
  
      HttpRequestMessage requestMessage = new HttpRequestMessage&lt;T&gt;(data, mediaType, new MediaTypeFormatter[] { jsonFormatter });
  
      return requestMessage;
  }
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <pre><code>Error   3   The non-generic type 'System.Net.Http.HttpRequestMessage' 
  cannot be used with type arguments.
  </code></pre>
  
  <p>Where <code>HttpRequestMessage&lt;T&gt;</code> is underlined with a red squiggly.</p>
  
  <p>How would I rewrite this routine/line of code in a way that will not break the generic usefulness of this class?</p>