How can I convert this .NET RestSharp code to Microsoft.Net.Http HttpClient code?
.net, c#, dotnet-httpclient, restsharp
Solution
This should do it
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("ILikeTurtles", "true");
var parameters = new Dictionary<string, string>();
parameters["Email"] = "myemail";
parameters["Password"] = "password";
var result = await httpClient.PostAsync("http://www.example.com/", new FormUrlEncodedContent(parameters));
Problem
I'm trying to figure out how to use `HttpClient` to `POST` some simple parameters. - Email - Password I've been doing this with RestSharp, but I'm trying to migrate off that. How can I do this with `HttpClient`, please? I have the following RestSharp code ``` var restRequest = new RestRequest("account/authenticate", Method.POST); restRequest.AddParameter("Email", email); restRequest.AddParameter("Password", password); ``` How can I convert that to use the `(Microsoft.Net.Http) HttpClient` class, instead? Take note: I'm doing a POST Also, this is with the PCL assembly. Lastly, can I add in a custom header. Say: `"ILikeTurtles", "true"`.