0

I need to convert this restsharp code to c# HttpClient code. How would I go about that?

var client = new RestClient("http://localhost:61375/token");
var request = new RestRequest(Method.POST);    
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", 
"grant_type=password&username=UserName&password=pa%24%24w0rd", 
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Rocco
  • 457
  • 5
  • 23
  • Please [research](http://meta.stackoverflow.com/questions/261592) your question. If you have a problem you can **post what you've tried** with a **clear explanation of what isn't working** and providing a **[mcve]**. I suggest reading [ask] a good question and [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/). – ProgrammingLlama Apr 10 '17 at 11:33
  • http://stackoverflow.com/questions/5665558/c-sharp-httpwebrequest-of-type-application-x-www-form-urlencoded-how-to-send – ProgrammingLlama Apr 10 '17 at 11:59

0 Answers0