- Home /
 
 
               Question by 
               renezuidhof · May 19, 2015 at 07:44 PM · 
                wwwwwwform  
              
 
              Content-Length mismatch: Request Header indicated x bytes, but client sent 0 bytes.
I have been working some code to upload a file to SoundCloud with the WWW class (http://answers.unity3d.com/questions/966993/www-wwwform-and-soundcloud.html). I can't get it to work so i started the thread in the link above. Now after some more investigation it seems that the problem is that the WWW class is not sending the files i add with wwwform.AddBinaryData.
Does someone know what i am doing wrong?
 public IEnumerator UploadFileWebClient(FileInfo file)
     {
         //Started as Coroutine
         ServicePointManager.Expect100Continue = false;
         byte[] fileContents = File.ReadAllBytes(file.FullName);
 
         WWWForm form = new WWWForm();
 
         form.AddField("track[title]", "Some title");
         form.AddField("track[sharing]", "private");
         form.AddField("oauth_token", soundCloudToken);
         form.AddField("format", "json");
         form.AddBinaryData("track[asset_data]", fileContents, file.FullName, "multipart/form-data"); //Also tried "application/octet-stream"
 
         WWW download = new WWW("https://api.soundcloud.com/tracks", form);
         yield return download;
 
         if(!string.IsNullOrEmpty(download.error)) 
         {
             Debug.Log ( "Error downloading: " + download.error );
         } 
         else 
         {
             Debug.Log(download.text);
         }
     }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
WWWForm.Addfield not able to post data to server 1 Answer
Sending cookie to XML-RPC protocol 0 Answers
Unity Facebook 400 Bad Request 0 Answers
WWW.Addformfield posts only some values 0 Answers