title: How do I use HttpClient PostAsync parameters properly?
body: <p>So I am working on writing an extension class for my project using HttpClient since I am moving over from HttpWebRequest.</p>
  
  <p>When doing the POST request, how do I send a normal string as a parameter? No json or anything just a simple string.</p>
  
  <p>And this is what it looks like so far.</p>
  
  <pre><code>static class HttpClientExtension
      {
          static HttpClient client = new HttpClient();
          public static string GetHttpResponse(string URL)
          {
              string fail = "Fail";
              client.BaseAddress = new Uri(URL);
              HttpResponseMessage Response = client.GetAsync(URL).GetAwaiter().GetResult();
              if (Response.IsSuccessStatusCode)
                  return Response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
              else
                  return fail;
          }
  
          public static string PostRequest(string URI, string PostParams)
          {
              client.PostAsync(URI, new StringContent(PostParams));
              HttpResponseMessage response = client.GetAsync(URI).GetAwaiter().GetResult();
              string content = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
              return content;
          }
      }
  </code></pre>
  
  <p>If you look at this like</p>
  
  <pre><code>client.PostAsync(URI, new StringContent(PostParams));
  </code></pre>
  
  <p>You can see that I just tried creating new StringContent and passing a string into it and the response returned 404 page not found.
  How do I properly use Post.Async(); do I send a string or byte array? Because with HttpWebRequest you would do it like this</p>
  
  <pre><code>public static void SetPost(this HttpWebRequest request, string postdata)
          {
              request.Method = "POST";
              byte[] bytes = Encoding.UTF8.GetBytes(postdata);
  
              using (Stream requestStream = request.GetRequestStream())
                  requestStream.Write(bytes, 0, bytes.Length);
          }
  </code></pre>