- Home /
Adding Custom Headers/Cookies to the UnityWebRequest.Post
Dear developers, I have problems about adding custom headers to my web requests. I would be appreciated if you help me.
UnityWebRequest www = UnityWebRequest.Post(Url, form);
www.SetRequestHeader("cookie", "sid=" + SessionManager.Instance.User.Sid);
www.SetRequestHeader("cookie", "proxyAddress=" + SessionManager.Instance.User.ProxyAdress);
www.SetRequestHeader("cookie", "ruleVersion=" + SessionManager.Instance.User.RuleVersion);
www.SetRequestHeader("cookie", "downloadManagerAddress=" + SessionManager.Instance.User.DownloadManagerAdress);
If I use the "cookie" as request header name it gives that error : Refused to set unsafe header "cookie"
UnityWebRequest www = UnityWebRequest.Post(Url, form);
www.SetRequestHeader("Cookie", "sid=" + SessionManager.Instance.User.Sid);
www.SetRequestHeader("Cookie", "proxyAddress=" + SessionManager.Instance.User.ProxyAdress);
www.SetRequestHeader("Cookie", "ruleVersion=" + SessionManager.Instance.User.RuleVersion);
www.SetRequestHeader("Cookie", "downloadManagerAddress=" + SessionManager.Instance.User.DownloadManagerAdress);
If I use "Cookie" as a request header name it gives that error: InvalidOperationException: Cannot override system-specified headers
I'm trying to build for WebGL.I in the scriptingAPI Unity says UnityWebRequest class is supported at WebGL.
Dear develepoers pls help me about that. Is it not available adding custom headers to the UnityWebRequest. If so, I need to change my backend services so need to know. It is boring if it does not support adding custom headers waste of time.
Answer by berkanmamak · Apr 03, 2018 at 12:19 PM
I Still have taking that error
with that code;
webRequest.SetRequestHeader("Cookie", "sid=" + SessionManager.Instance.User.Sid + ";" +"proxyAddress=" + SessionManager.Instance.User.ProxyAdress + ";" + "ruleVersion=" + SessionManager.Instance.User.RuleVersion + ";" + "downloadManagerAddress=" + SessionManager.Instance.User.DownloadManagerAdress);
I got that, I think this site is all illusion, worst product community and forum ever.
Your answer
Follow this Question
Related Questions
New UnityWebRequest How Can I Handle the responses ?? 1 Answer
http url not work in webgl (unity2019.3). 2 Answers
Connection slower with higher update rate using LLAPI. webgl 0 Answers
Serious Bug UnityWebRequest.SetRequestHeader is not working in non development mode on Android 1 Answer
Is it possible to get a networked WebGL build to run in single player mode? 2 Answers