title: How to set the Content-Type header for a RestRequest?
body: <p>I have a web service in a RESTful web server (java) which consumes media of type <strong><em>MULTIPART_FORM_DATA</em></strong> and produces <em>APPLICATION_JSON</em>. I'm working on a REST client (C#) and using this web service. I'm using RestSharp as the REST client. My code goes as follows: </p>
  
  <pre><code>RestRequest request = new RestRequest("addDelivery", Method.POST);
  
  request.AddParameter("sessionId", this.sessionId);
  request.AddParameter("deliveryTo", DeliveryTo);
  request.AddParameter("deliveryName", DeliveryName);
  
  if (fileList.Count() &gt; 0) // If fileList is not empty
  {
      // Adds all the files to request
      foreach (MyFile myFile in fileList)
      {
          request.AddFile(myFile.fileName, myFile.filePath);
      }
  }
  </code></pre>
  
  <p>It works fine as long as I provide a file(s). If a file isn't provided (<code>fileList</code> is empty) I'm getting <strong>HTTP Status 415 - Unsupported Media Type</strong>. I think as I'm not providing any file the <code>Content-Type</code> is automatically changed to some type other than <code>multipart/form-data</code>. But the web service consumes <strong><em>MULTIPART_FORM_DATA</em></strong> and maybe that's why getting this error. I've tried adding the following code segment but getting the same error:</p>
  
  <pre><code>request.AddHeader("Content-Type", "multipart/form-data");
  </code></pre>
  
  <p>Note that this action(sending request without files) can be performed successfully from other clients (java, ios)</p>