将restsharp转换为httpclient

时间:2017-04-10 10:13:41

标签: c# restsharp

我需要将此restsharp代码转换为c#HttpClient代码。 我该怎么办呢?

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

0 个答案:

没有答案