title: how to send body parameter and file with httpclient in c#
body: <p>I have web service and i want to send to this web service parameter value&amp;key like token = "" and file </p>
  
  <pre><code>client - &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;send&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;web service
  token = "exmple"
  userfile = sound file
  
  web service (get both) &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;send&gt;&gt;&gt;&gt;&gt;&gt; client
  result as Json
  </code></pre>
  
  <p>like as Postman :
  <a href="https://i.stack.imgur.com/GhVL6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GhVL6.png" alt="enter image description here"></a></p>
  
  <p>i write this code in c# but web service cannot get both token and file. but not working.Where I was wrong?means data send to web service.but service not get token and file.</p>
  
  <pre><code>        byte[] array;
          string filename;
          if (openFileDialog1.ShowDialog() == DialogResult.OK)
          {
              var client = new HttpClient();
              var requestContent = new MultipartFormDataContent();
              filename = openFileDialog1.FileName;
              array = File.ReadAllBytes(filename);
              var imageContent = new ByteArrayContent(array);
              imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("audio/*");
              requestContent.Add(imageContent, "audio", "audio.wav");
              var values = new Dictionary&lt;string, string&gt;
              {
              { "token", "111fhgbbrvjndskbsd" },
              };
              var content = new FormUrlEncodedContent(values);
              requestContent.Add(content);
              var response = await client.PostAsync("example.com/upload", requestContent);
              var responseString = await response.Content.ReadAsStringAsync();
              txtbox.Text = responseString.ToString();
          }
  </code></pre>