title: C# HttpClient: How to send query strings in POST Requests
body: <p>This is the POST Request, it works.</p>
  <pre><code>curl -X POST --header 'Accept: application/json' 
  
  'http://mywebsite.com/api/CompleteService?refId=12345&amp;productPrice=600'
  </code></pre>
  <p>How to send this request using  <code>C#</code> =&gt; <code>HttpClient</code> =&gt; <code>client.PostAsync()</code> method?
  Two methods have been tried but both failed.</p>
  <br/>
  <p><strong>Method 1 (Failed, Response 404)</strong></p>
  <pre><code>string url = &quot;http://mywebsite.com/api/CompleteService&quot;;
  string refId = &quot;12345&quot;;
  string price= &quot;600&quot;;
  string param = $&quot;refId ={refId}&amp;productPrice={price}&quot;;
  HttpContent content = new StringContent(param, Encoding.UTF8, &quot;application/json&quot;);
  HttpResponseMessage response = client.PostAsync(url, content).Result;
  </code></pre>
  <p>This would only work if API is to accept a request body, not query strings.</p>
  <br>
  <p><strong>Method 2 (Failed, Response  404)</strong>
  <a href="https://stackoverflow.com/a/37443799/7768490">https://stackoverflow.com/a/37443799/7768490</a></p>
  <pre><code>var parameters = new Dictionary&lt;string, string&gt; { { &quot;refId &quot;, refId }, { &quot;productPrice&quot;, price} };
  var encodedContent = new FormUrlEncodedContent(parameters);
  HttpResponseMessage response = client.PostAsync(url, encodedContent)
  </code></pre>