Archived Forum Post

Index of archived forum posts

Question:

Post HTTPS with Content-Type

Jul 22 '16 at 13:46

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);

Answer

Can you explain how it's not working? In particular, can you post the contents of the LastErrorText property as defined immediately after the first failing call?


Answer

Yes i using last version Chilkat Lib. And how it's not working because website detected content type post is = "application/x-www-form-urlencoded" , but if u post with another content type website show nothing. If you use HTTP POST addon of firefox u can see that. U post with another content type it's never show anything, but if u post with content type "application/x-www-form-urlencoded" it's working


Answer

What happens if you don't URL encode your parameter names (that is, instead of %2F us the / character)?

Also how about explicitly setting the HttpVerb property of the request object to "POST"?


Answer

ok, i got new problem, when i add http.autoredirect. it show : GET /account/login.jsp?_requestid=241874&_dyncharset=ISO-8859-1 &_dynSessConf=4854342059940592074&/atg/userprofiling/ProfileFormHandler.value.login=email%40email.com&_D:/atg/userprofiling/ProfileFormHandler.value.login=%20&/atg/userprofiling/ProfileFormHandler.value.password=1234567&_D:/atg/userprofiling/ProfileFormHandler.value.password=%20&newStrongPassword= &_D:newStrongPassword=%20&loginAttemptsOverThreshold=true &/atg/userprofiling/ProfileFormHandler.login=Submit &_D:/atg/userprofiling/ProfileFormHandler.login=%20 &/atg/userprofiling/ProfileFormHandler.employeeProfile= &_D:/atg/userprofiling/ProfileFormHandler.employeeProfile=%20&/atg/userprofiling/ProfileFormHandler.refererURL=https%3A%2F%2Fwww.neimanmarcus.com%2Faccount%2Flogin.jsp%3F_requestid%3D193974 &_D:/atg/userprofiling/ProfileFormHandler.refererURL=%20&/atg/userprofiling/ProfileFormHandler.refererURL=http%3A%2F%2Fwww.neimanmarcus.com%2F &_D:/atg/userprofiling/ProfileFormHandler.refererURL=%20&_DARGS=%2Fpage_rwd%2Faccount%2Flogin.jsp&_DARGS=%2Fpage_rwd%2Faccount%2Flogin.jsp HTTP/1.1 it's wrong. how to delete when auto redirect on?