I'm getting the website form by htmlagilitypack, setting the form variable and trying to submit the form. Everything looks that is working fine, but the response from the form submit is null.
static void Main(string[] args)
{
string urlAddress = "mywebsite";
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load(urlAddress);
// Post link
var post = doc.GetElementbyId("post").GetAttributeValue("href", "");
doc = web.Load(post);
// get the form
var form = doc.DocumentNode.SelectSingleNode("//form[@class='picker']");
// get the form URI
string actionValue = form.Attributes["action"]?.Value;
System.Uri uri = new System.Uri(actionValue);
// Populate the form variable
var formVariables = new List<KeyValuePair<string, string>>();
formVariables.Add(new KeyValuePair<string, string>("id", "ho"));
var formContent = new FormUrlEncodedContent(formVariables);
// submit the form
HttpClient client = new HttpClient();
var response = client.PostAsync(uri, formContent);
}
Does anyone know why my variable response is null?
Thanks