- Home /
Adding header info to www "GET" method.
Is that possible to add header information in the GET method of the built in www request. I've done the following code in Corona and what's the similar version to Unity. WWWform can add headers and it can be used only for POST method.
gamer info local params = {}; params.headers = headers; params.body = "email=" .. tempRivalID .. "&password=" .. tempPwd;
network.request( "http://happycat.xtremebit.net/gpi/gamer?session_key=" .. sessionKey, "GET", gamerInfoListener, params);
Answer by delsolu · Sep 19, 2013 at 06:22 AM
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);
Thanks for the input! Saved my day. All over the place you got folks saying Unity can't make GET requests with header.
Because this feature did not originally exist. Notice I, myself said currently, which was true at that time.
I see. At the time that statement was true. But searching now it may be misleading if you dont look at the post date. But thanks for the input too!
You're 100% right, but I'm guessing until Google search uses some algorithm to make obsolete answers in forums, at least technical ones, less apparent, these will continue to plague us.
Answer by GuyTidhar · Jun 23, 2011 at 09:03 AM
unity currently does not support custom headers for a GET request.
Your answer
Follow this Question
Related Questions
Custom Header with WWW Get 0 Answers
GET Request Wrapper 1 Answer
See Request of WWW or UnityWebRequest, 403 error only from android in a specific url (GET) 2 Answers
HTTP Response Headers? 3 Answers