title: Sending an HTTP PUT request with a parameter in C#
body: <p>I have a tika server open on my PC, and I need to send it a request with a string parameter which is a path for a file I want tika to process. The code I have so far is:</p>
  
  <pre><code>private void getFromServer(string fileName)
  {
      var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:9998/rmeta");
      httpWebRequest.Accept = "application/json";
      httpWebRequest.Method = "PUT";
      httpWebRequest.KeepAlive = true;
  
      using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
      {
          string postData = @"C:\Users\######\Downloads\elasticsearch\elasticsearch-1.7.1.zip";
          byte[] byteArray = Encoding.ASCII.GetBytes(postData);
  
          string json = postData;
  
          streamWriter.Write(json);
      }
      var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
      using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
      {
          var responseText = streamReader.ReadToEnd();
          //Now you have your response.
          //or false depending on information in the response
          console.write(responseText);
      }
  }
  </code></pre>
  
  <p>The thing is, the server gets the request, but it returns the string I sent it instead of the contents of the file in question, and I know it can work because I sent it the same request using a cURL command and it worked. Any ideas what I'm doing wrong?</p>
  
  <p>PS the hashtags are instead of my username</p>