I am trying to send data to a webserver via WWWForm but I get this error. Looking into apache logs, I can see unity accessing the requested page but there is no error in logs. The server side code is ok, I’ve tested it with a GET from unity and is doing what is suppose to do. But when I switch to sending data with wwwform via POST I get “500 Internal Server Error” no matter what i do.
Using GET like this WWW www = new WWW(url + “?field1=”+value1+“&field2=value”+“&field3=”+value3); works as intended without any error.
Here is a test I’ve done outside of my game:
using UnityEngine;
using System.Collections;
public class senddata : MonoBehaviour
{
private bool once = false;
WWW www = null;
void OnGUI()
{
if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 20, 200, 40), "Send"))
{
StartCoroutine("Send");
}
}
IEnumerator Send()
{
WWWForm form = new WWWForm();
form.AddField("f1", "value 1", System.Text.Encoding.UTF8);
form.AddField("f2", "value 2", System.Text.Encoding.UTF8);
form.AddField("f3", "value 3", System.Text.Encoding.UTF8);
www = new WWW("obscured", form);
yield return www;
if(!string.IsNullOrEmpty(www.text) !once)
{
Debug.Log(www.text);
once = true;
}
}
}