title: How to properly do this C# MultiPartFormDataContent API Call?
body: <p>I am currently trying to make an api call in c# using a MultiPartFormDataContent but I keep
  getting the following error:</p>
  <p>&quot;Response: {&quot;statusCode&quot;:400,&quot;error&quot;:&quot;Bad Request&quot;,&quot;message&quot;:&quot;&quot;Image file&quot; must be of type object&quot;,&quot;validation&quot;:{&quot;source&quot;:&quot;payload&quot;,&quot;keys&quot;:[&quot;images&quot;]}}&quot;</p>
  <p>This is my Code:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Net.Http;
  using System.Net.Http.Headers;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace Example
  {
      public class Test
      {
          public static void Main(string[] args)
          {
              Task&lt;string&gt; test = testFunction();
              Console.WriteLine(&quot;Result: &quot; + test.Result);
          }
  
          public static async Task&lt;string&gt; testFunction()
          {
              const string file = &quot;C:\\ExamplePath\\image_1.jpeg&quot;;
              const string URL = &quot;https://example-api?api-key=example-key&quot;;
  
              string boundary = &quot;---8d0f01e6b3b5dafaaadaad&quot;;
              MultipartFormDataContent multipartContent = new MultipartFormDataContent(boundary);
  
              var streamContent = new StreamContent(File.Open(file, FileMode.Open));
              var stringContent = new StringContent(&quot;flower&quot;);
  
              multipartContent.Add(stringContent, &quot;organs&quot;);
              multipartContent.Add(streamContent, &quot;images&quot;);
  
              try
              {
                  HttpClient httpClient = new HttpClient();
                  HttpResponseMessage response = await httpClient.PostAsync(URL, multipartContent);
  
                  Console.WriteLine(&quot;Response: &quot; + await response.Content.ReadAsStringAsync());
  
                  if (response.IsSuccessStatusCode)
                  {
                      string content = await response.Content.ReadAsStringAsync();
                      Console.WriteLine(&quot;IN METHIOD: &quot; + content);
                      return content;
                  }
                  return null;
              }
              catch (Exception e)
              {
                  Console.WriteLine(e.Message);
                  return null;
              }
          }
      }
  }
  </code></pre>
  <p>It's obviously a problem with how I am trying to do the api call but I don't know how to do it with an object instead like mentioned the error message.</p>