Currently, I’m changing some selenium automations for web scraping on a website that uses java faces .jsf, when trying to make a request with C# and httpclient
the server responds with an xml error:
faces.application.ViewExpiredException
This is an example of the body HTTP call I’m using:
var postData = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("ice.window", "pnm15d2rfi"),
new KeyValuePair<string, string>("ice.view", "v98u1snc8nx:0"),
new KeyValuePair<string, string>("form:num_contrato_input", $"{varnumber}"),
new KeyValuePair<string, string>("form_SUBMIT", "1"),
new KeyValuePair<string, string>("javax.faces.ClientWindow", "pnm15d2rfi"),
new KeyValuePair<string, string>("javax.faces.ViewState", $"{Viewstate}"),
new KeyValuePair<string, string>("com.sun.faces.namingContainerId", ""),
new KeyValuePair<string, string>("ice.focus", "form:checkAuthBtn_Consultar"),
new KeyValuePair<string, string>("form:checkAuthBtn_Consultar", "Consultar"),
new KeyValuePair<string, string>("ice.event.target", "form:checkAuthBtn_Consultar"),
new KeyValuePair<string, string>("ice.event.captured", "form:checkAuthBtn_Consultar"),
new KeyValuePair<string, string>("ice.event.type", "onclick"),
new KeyValuePair<string, string>("ice.event.alt", "false"),
new KeyValuePair<string, string>("ice.event.ctrl", "false"),
new KeyValuePair<string, string>("ice.event.shift", "false"),
new KeyValuePair<string, string>("ice.event.meta", "false"),
new KeyValuePair<string, string>("ice.event.x", "840"),
new KeyValuePair<string, string>("ice.event.y", "274"),
new KeyValuePair<string, string>("ice.event.left", "true"),
new KeyValuePair<string, string>("ice.event.right", "false"),
new KeyValuePair<string, string>("ice.submit.type", "ice.s"),
new KeyValuePair<string, string>("ice.submit.serialization", "form"),
new KeyValuePair<string, string>("javax.faces.partial.event", "click"),
new KeyValuePair<string, string>("javax.faces.source", "form:checkAuthBtn_Consultar"),
new KeyValuePair<string, string>("javax.faces.partial.ajax", "true"),
new KeyValuePair<string, string>("javax.faces.partial.execute", "@all"),
new KeyValuePair<string, string>("javax.faces.partial.render", "@all"),
new KeyValuePair<string, string>("form", "form")
});
var responsePost = await client.PostAsync(URLWEBSITE, postData);
var resultContent = await responsePost.Content.ReadAsStringAsync();
Console.WriteLine(resultContent);
Am I missing something? It is necessary to decrypt the viewstate?
I tried use one hardcoded value in view state
New contributor
Alessandro Colluci Jr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.