title: C# HttpClient request API suite
body: <p>I'm trying to develop an API suite so I can call it by passing some parameters. I successfully made the part about GET method.
  POST seems a bit more complicated and I didn't find any source so I can understand how to make it. My plan is to call in POST with a body as parameter</p>
  <p>I didn't develop the API I'm going to POST but it's not even a public one but inside the project development. Using .NET core 5.0. The scope is to call some APIs as regression tests before any deploy from the dev team and some of them might return a data that will be used as body param in the next API so I'm developing a console app that check if everything is OK.</p>
  <p>This is the GET request I developed, could you help me understand how to make it using POST method?:</p>
  <pre><code>static void Main(string[] args)
      {
          string url = ConfigurationManager.AppSettings[&quot;url&quot;];
          string jsonBody = &quot;&quot;;
          string method = &quot;GET&quot;;
          string result = CallApi(url, method, jsonBody);
      }
  
      public static string CallApi(string url, string method, string bodyInput)
      {
          string bodyOutput = null;
          HttpClient client = new();
          Uri uri = new(url);
  
          switch (method)
          {
              case &quot;GET&quot;:
                  Task&lt;HttpResponseMessage&gt; response = client.GetAsync(uri);
                  HttpResponseMessage result = response.Result;
                  HttpContent content = result.Content;
                  bodyOutput = content.ReadAsStringAsync().Result;
                  break;
  
              case &quot;POST&quot;:
                  //bodyInput
                  break;
  
              case &quot;PUT&quot;:
                  break;
  
              case &quot;DELETE&quot;:
                  break;
  
              default:
                  break;
          }
  
          return bodyOutput;
      }
  }
  </code></pre>
  <p>Thanks</p>