- Home /
WWW zero sized post buffer error Standalone
Hi
When I try to make a WWW request via a WWWForm I allways get an error saying: "You are trying to load data from a www stream which had the following error when downloading. Error when creating request. POST request with a zero-sized post buffer is not supported. UnityEngine.WWW:get_text()" This however only happens if the Platform in the Build Settings is set to "PC and MAC Standalone". If I switch the platform to Web Player everything works perfectly. Anyone an idea what might be causing this? Thx in advance.
private void MakeRequest(Uri url, HttpVerb httpVerb,
Dictionary<string, string> args, Action<JsonData> method)
{
string requestString = url.ToString();
if (args != null && args.Keys.Count > 0 && httpVerb == HttpVerb.GET)
{
requestString += EncodeDictionary(args, true);
}
WWWForm form = new WWWForm();
// Create a download object
download = new WWW(requestString, form);
if(method != null)
StartCoroutine(WaitForDownload(download, method));
}
private IEnumerator WaitForDownload(WWW download, Action<JsonData> method)
{
yield return download;
JsonData data;
if (download.error == null)
{
Debug.Log(download.text);
data = JsonMapper.ToObject(download.text);
}
else
{
Debug.Log(download.error);
string error = "{\"" + "error\"" + " : " + "\"" + download.error + "\"" + "}";
Debug.Log(error);
data = JsonMapper.ToObject(error);
}
if(method != null)
method(data);
}
Answer by Mike 3 · May 23, 2011 at 01:31 PM
Do you need to send the data as POST instead of GET?
If not, you could skip on the WWWForm and just do new WWW(requestString)
If you do, I guess you could add some (short) simple data into the form so it doesn't give you the error, though send in a bug report about it
I would do the same. If you need a POST request but you don't care for any posted data, just do form.data = new byte[1]{0};
or something like that. If you don't need a POST just remove the WWWForm. The error is quite self explaining ;)
Ahh, my bad... WWWForm.data is read only... You have to use AddField ins$$anonymous$$d :/
Your answer
Follow this Question
Related Questions
Unity5 WebPlayer WWWForm working only in Google Chrome 3 Answers
www in web player and standalone 3 Answers
WWW Request runs in Editor but not in Webplayer 1 Answer
GET Request Wrapper 1 Answer