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:\ estingfile.txt");
WWWForm form = new WWWForm();
form.AddField("downloadableId", "testingfile");
form.AddField("apiKey", "{myapikey}");
form.AddBinaryData("formData", bytes, "D:\ estingfile.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");
}
}