How can I add header information to make the GET request from Unity www class. I use headers in POST method as below and it works..
WWWForm form = new WWWForm();
form.AddField("email", email);
form.AddField("password", password);
byte[] rawData = form.data;
Now, I am trying to get the gamer information with GET request and I've no idea of how to make it... I tried the same as before and WWWForm is for POST only.
The key is leaving “postData” parameter to null. From Unity3D WWW reference
The WWW class will use GET by default
and POST if you supply a postData
parameter.
So this one works for me:
var form = new WWWForm();
var headers = new Hashtable();
headers.Add("Header_key", "Header_val");
www = new WWW("http://localhost/getpostheaders", null, headers);
yield return www;
Debug.Log("2. " + www.text);