When I try to use UnityWebRequest.Put() I get the error aforementioned.
------
I am hosting my game on HostGator.
I've asked their tech support but they have no idea and they say I should consult with a Web Developer.
So instead I'm consulting with this amazing community.
---
I want to state that my initial plan was to use UnityWebRequest.Post(), but I can't find a way to send byte[] through this function. It is only possible to do so with the UnityWebRequest.Put() function.
---
This is the part of my code where I try to upload a new binary file:
public static PlayerData[] OldPlayersData;
public static IEnumerator SavePlayer(PlayerData player)
{
byte[] finalDataToSend;
PlayerData[] newData = new PlayerData[] { player };
newData = newData.Concat(OldPlayersData);
BinaryFormatter bf = new BinaryFormatter();
using (MemoryStream ms = new MemoryStream())
{
bf.Serialize(ms, newData);
finalDataToSend = ms.ToArray();
}
UnityWebRequest www = UnityWebRequest.Put(putPlayersURL, finalDataToSend);
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.LogError(www.error);
}
else
{
Debug.Log("done");
}
}
---
**Bottom line, my questions are:**
1. Is there a way to make this method allowed? If not, is there a work-around?
2. Is there really no way to send byte[] data through UWR.Post()?
3. Please help my solve this in any other way. This is crucial to me.
↧