When i tried post URL web with content-type : application/x-www-form-urlencoded. but it not working. i using request.ContentType = "application/x-www-form-urlencoded"; and set header, but both is not working, i am receving header with contentType:text/html. How to fix it ?
Http http = new Http();
bool success;
http.SocksHostname = "127.0.0.1";
http.SocksPort = 50000;
http.SocksVersion = 5;
http.CookieDir = "memory";
http.SaveCookies = true;
http.SendCookies = true;
// Any string unlocks the component for the 1st 30-days.
success = http.UnlockComponent("Anything for 30-day trial");
if (success != true)
{
Console.WriteLine(http.LastErrorText);
return;
}
HttpRequest request = new HttpRequest();
request.ContentType = "application/x-www-form-urlencoded";
//Content-Type: application/x-www-form-urlencoded
// Add the form parameters to the HTTP request:
request.AddParam("_dyncharset", "ISO-8859-1");
request.AddParam("_dynSessConf", "6268568803919292891");
request.AddParam("%2Fatg%2Fuserprofiling%2FProfileFormHandler.value.login", "tester@gmail.com");
request.AddParam("_D%3A%2Fatg%2Fuserprofiling%2FProfileFormHandler.value.login", "+");
request.AddParam("%2Fatg%2Fuserprofiling%2FProfileFormHandler.value.password", "123456");
request.AddParam("_D%3A%2Fatg%2Fuserprofiling%2FProfileFormHandler.value.password", "+");
request.AddParam("newStrongPassword", "");
request.AddParam("_D%3AnewStrongPassword", "+");
request.AddParam("%2Fatg%2Fuserprofiling%2FProfileFormHandler.login", "Submit");
request.AddParam("_D%3A%2Fatg%2Fuserprofiling%2FProfileFormHandler.login", "+");
request.AddParam("%2Fatg%2Fuserprofiling%2FProfileFormHandler.employeeProfile", "");
request.AddParam("_D%3A%2Fatg%2Fuserprofiling%2FProfileFormHandler.employeeProfile", "+");
request.AddParam("%2Fatg%2Fuserprofiling%2FProfileFormHandler.refererURL", "http%3A%2F%2Fwww.neimanmarcus.com%2Findex.jsp%3Fnavid%3DaccountLogout%26_requestid%3D385928");
request.AddParam("_D%3A%2Fatg%2Fuserprofiling%2FProfileFormHandler.refererURL", "+");
request.AddParam("%2Fatg%2Fuserprofiling%2FProfileFormHandler.refererURL", "http%3A%2F%2Fwww.neimanmarcus.com%2Findex.jsp%3Fnavid%3DaccountLogout%26_requestid%3D385928");
request.AddParam("_D%3A%2Fatg%2Fuserprofiling%2FProfileFormHandler.refererURL", "+");
request.AddParam("_DARGS", "%2Fpage_rwd%2Faccount%2Flogin.jsp");
// Send the HTTP POST by calling PostUrlEncoded.
// The Content-Type used w/ the request will be application/x-www-form-urlencoded
HttpResponse response = null;
response = http.PostUrlEncoded("https://www.neimanmarcus.com/min.jsp?_DARGS=/page_rwd/account/login.jsp", request);
if (response == null)
{
Console.WriteLine(http.LastErrorText);
return;
}
string[] str;
Console.WriteLine(response.Header + response.BodyStr);