title: .NET HttpClient add query string and JSON body to POST
body: <p>How do I set up a .NET HttpClient.SendAsync() request to contain query string parameters and a JSON body (in the case of a POST)?</p>
  
  <pre><code>// Query string parameters
  var queryString = new Dictionary&lt;string, string&gt;()
  {
      { "foo", "bar" }
  };
  
  // Create json for body
  var content = new JObject(json);
  
  // Create HttpClient
  var client = new HttpClient();
  client.BaseAddress = new Uri("https://api.baseaddress.com/");
  
  var request = new HttpRequestMessage(HttpMethod.Post, "something");
  // Setup header(s)
  request.Headers.Add("Accept", "application/json");
  // Add body content
  request.Content = new StringContent(
      content.ToString(),
      Encoding.UTF8,
      "application/json"
  );
  
  // How do I add the queryString?
  
  // Send the request
  client.SendAsync(request);
  </code></pre>
  
  <p>Every example I've seen says to set the </p>
  
  <pre><code>request.Content = new FormUrlEncodedContent(queryString)
  </code></pre>
  
  <p>but then I lose my JSON body initialization in the <code>request.Content</code></p>