简体   繁体   中英

RestSharp to httpwebrequest converting process

I am trying to make a api call to " https://api.getresponse.com/v3 " with header "X-Auth-Token: api-key jfgs8jh4ksg93ban9Dfgh8" i already did it with RestSharp library bellow but somehow this not works. So i want to try same thing with httpwebrequest. Please provide an example same request using httpwebrequest i am new to c# that's why need help. Thanks in advance

 var client = new RestClient("https://api.getresponse.com/v3");
 var request = new RestRequest("/campaigns/", Method.POST);

 request.AddHeader("Content-Type", "application/json");
 request.AddHeader("X-Auth-Token:", "api-key 948dff91a017a07f3c6");
 request.Parameters.Clear();

 var response = client.Execute(request);

You say you want to send a header, but you do

request.AddParameter("X-Auth-Token:", "api-key 948dff91a017a07f3c6");

Moreover you do Parameters.Clear after that. Maybe changing this to AddHeader will work?

Otherwise, please provide us with more details on what exactly does not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM