KnightM
KnightM

Reputation: 25

C# RestSharp Library AddHeader Method not work

Here is my code:

 var cclient = new RestClient("ex.com");
 var reqq = new RestRequest("ex", Method.POST);
 reqq.AddHeader("Cookie", coockie);
 reqq.AddHeader("Host", "profile.callofduty.com");
 reqq.AddHeader("Pragma", "no-cache");
 reqq.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
 reqq.AddParameter("username", log);     
 reqq.AddParameter("password", pas);                      
 var responsee = cclient.Post(reqq);

but on http debugger when I inspect the request: enter image description here

I Don't now the problem please help. none of headers submited

Upvotes: 0

Views: 849

Answers (1)

Lemm
Lemm

Reputation: 196

AddHeader(key, value) method is a "proxy" for AddParameter(key, value, ParameterType.HttpHeader) method. All your headers are applied to the request and can be found using ordinary debugger if you inspect Parameters property of your RestRequest instance (in your code sample it's reqq).

Also to send your request you really should use the Execute(IRestRequest) method in your RestClient

Upvotes: 1

Related Questions