I am figuring out the new HttpClient
.
I try to POST a http uri like this:
http://server/API/user/login?login=name&password=password
I thought this would be the way to go:
using (var client = new HttpClient())
{
var values = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("login", "user"),
new KeyValuePair<string, string>("password ", "password")
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://server/REST/user/login", content);
}
The only way I can get it to work is:
using (var client = new HttpClient())
{
var response = await client.PostAsync("http://server/REST/user/login?login=user&password=password",null);
}
Is the last way the correct way or am I doing something wrong in the first approach?