title: Upload File using httpwebrequest and rest api
body: <pre><code>  I am trying to upload file using httpwebrequest and rest api
  </code></pre>
  
  <p>My code is like this i am not getting any error but i cannt able to upload file.
   <code>public static string RequestProfileUrl = "https://ws.onehub.com/workspaces/337426/folders/174352646/files/create?items[filename]=";</code></p>
  
  <pre><code>  if (file != null &amp;&amp; file.ContentLength &gt; 0)
          {
              byte[] bytearray = null;
              string name = "";
              long length = 0;
              string boundary = "----------------------------" +
              DateTime.Now.Ticks.ToString("x");
              name = file.FileName;
              Stream stream = file.InputStream;
              stream.Seek(0, SeekOrigin.Begin);
              bytearray = new byte[stream.Length];
              int count = 0;
              Stream memStream = new System.IO.MemoryStream();
              while (count &lt; stream.Length)
              {
                  bytearray[count++] = Convert.ToByte(stream.ReadByte());
              }
              //string baseAddress = "https://ws-api.onehub.com/workspaces/330201/files/";
              HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestProfileUrl + name);
              request.Method = "PUT";
              request.ContentType = "multipart/form-data"; 
              request.ContentLength = bytearray.Length;
              request.GetRequestStream().Write(bytearray, 0, bytearray.Length);
              using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
              {
  
                  int statusCode = (int)response.StatusCode;
                  StreamReader reader = new StreamReader(response.GetResponseStream());
                  string result = reader.ReadToEnd();
              }
  </code></pre>
  
  <p>i am not getting any error but my file is not uploading. i am not getting where is my error?
  any question free to ask
  Thanks in advance</p>