如何在Restsharp的请求中添加Cookie?

问题描述 投票:0回答:1

我试过request.AddHeader("Cookie",......,request.AddCookie和request.AddParameter("","",ParameterType.Cookie)。 ,request.AddCookie和request.AddParameter("","",ParameterType.Cookie).我试了request.AddHeader("Cookie",...,request.AddCookie)和request.AddParameter("",",ParameterType.Cookie).我嗅了嗅网状结构,Cookie没有发送。

c# restsharp
1个回答
0
投票

你需要把Cookie添加到 RestRequest 对象。

var client = new RestClient("<server_url>");
var request = new RestRequest("<resource_url>", Method.GET);
request.AddCookie("cookie_name", "cookie_value");
request.AddCookie("cookie_name2", "cookie_value2");
var result = client.Execute(request);
© www.soinside.com 2019 - 2024. All rights reserved.