Unable to send cookies with RestSharp

狂风中的少年 提交于 2019-12-04 04:52:17

RestSharp 102.4 seems to have fixed this problem.

 request.AddParameter(_cookie_name, _cookie_value, ParameterType.Cookie);

or, in your case

request.AddParameter(this.gallerySessionIdKey, this.sessionId, ParameterType.Cookie);

will work fine.

HttpWebRequest is the best to use. Simply user the CookieContainer to work with cookies. But you have to keep a reference of your CookieContainer over all your requests to get this work

CookieContainer cc = new CookieContainer();
HttpWebRequest webRequest = HttpWebRequest.CreateHttp(uri);
webRequest.CookieContainer = cc;
webRequest.BeginGetResponse((callback)=>{//Code on callback},webRequest);

cc must be referenced in your instance to be be reused on other request.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!