- Home /
 
               Question by 
               roshaantariq · Sep 29, 2018 at 01:28 PM · 
                errornetworkingserverupload  
              
 
              uploading file on server and keep getting an error
I'm trying to upload binary data onto server but unity keeps giving me error "could not connect to destination host"
below is my co-routine code:
 private IEnumerator UploadAssets()
     {
         yield return new WaitForSeconds(5);
         Debug.LogError("starting now");
 
         string baseURL = "http://config2.gamesparks.net/restv2/game/{myapikey}/config/~downloadables/testingfile/file";
         //string encodedURL = WWW.EscapeURL(baseURL);
 
         byte[] bytes = File.ReadAllBytes("D:\\testingfile.txt");
 
         WWWForm form = new WWWForm();
         form.AddField("downloadableId", "testingfile");
         form.AddField("apiKey", "{myapikey}");
         form.AddBinaryData("formData", bytes, "D:\\testingfile.txt", "text/plain");
         using (UnityWebRequest www = UnityWebRequest.Post(baseURL, form))
         {
             www.SetRequestHeader("Authorization", "{myusername/password}");
             www.SetRequestHeader("Accept", "application/json");
             yield return www.SendWebRequest();
             Debug.LogError(www.responseCode);
             Debug.LogError(www.GetResponseHeader("shortCode"));
             if (www.isNetworkError || www.isHttpError)
             {
                 Debug.Log(www.error);
             }
             else
             {
                 Debug.Log("Form upload complete!");
             }
 
             Debug.LogError("out");
        }
     }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Set up a server for downloading user built levels 4 Answers
Server still sending Packets to inactive clients and throwing errors. How can I stop it? 0 Answers
Networking error CreateSocketOrThreadFailure 0 Answers
Starting a small-scope client/server game with Unity 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                