Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add cookies to request in Restsharp?

Tags:

c#

restsharp

I tried:

  • request.AddHeader("Cookie", ....
  • request.AddCookie
  • request.AddParameter("","",ParameterType.Cookie).

I sniff the network but the cookies don't send.

like image 999
Fatemeh Panahi Avatar asked Sep 11 '25 15:09

Fatemeh Panahi


1 Answers

You need to add the cookies to the RestRequest object.

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);

Find more info about AddCookie API

like image 156
EylM Avatar answered Sep 13 '25 06:09

EylM