title: Upload a file via POST using RestSharp
body: <p>I'm trying to simulate a simple multipart HTML form in C#.</p>
  
  <p>I was successful posting text as parameters using the <code>addParameter</code> function.
  Now I want to upload a file using POST. I tried using the <code>addFile</code> function of the <code>RestRequest</code> object. But it did not work! I'm getting response code: 0.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>//preparing RestRequest by adding server url, parameteres and files...
  RestRequest request = new RestRequest("http://" + ipTextBox.Text + "/samplepost/postdata.php", Method.POST);
  
  request.AddParameter("msgpost", msgTextBox.Text);
  request.AddFile("file1", "NEVER.jpg");
  
  //calling server with restClient
  RestClient restClient = new RestClient();
  restClient.ExecuteAsync(request, (response) =&gt;
  {
       if (response.StatusCode == HttpStatusCode.OK)
       {
            //POST successful
            MessageBox.Show("Success!");                   
       }
       else
       {
            //error ocured during POST
            MessageBox.Show(":-(\nFailed.\nError: " + response.ErrorMessage);
       }
  });
  </code></pre>
  
  <p>Please help me find mistakes in my code.
  Thanks in advance!</p>