1

Im trying to replicate a site post as here: https://www.usbank.com/cgi_w/cfm/personal/products_and_services/reoPropertiesReq.cfm

I just want to post any state to see the results as they will end up in an email. This is my post method and it works for login etc on other sites so I know it works

public HtmlDocument POST(string url, string postData)
    {//string myParameters = "param1=value1&param2=value2&param3=value3";

        HtmlDocument hdoc = new HtmlDocument();
        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        using (wc)
        {
            hdoc.LoadHtml(wc.UploadString(url, postData));
        }

        return hdoc;
    }

I use it like:

HtmlDocument mainDoc = POST("https://www.usbank.com/cgi_w/cfm/personal/products_and_services/reoPropertiesReq.cfm",
            "selState=4&StateNM=Arizona");

But this seems incorrect. Can anyone analyse this site and identify if its my code or missing data??

Aaron Gibson
  • 1,280
  • 1
  • 21
  • 36
  • found a similar question here: http://stackoverflow.com/questions/5401501/how-to-post-data-to-specific-url-using-webclient-in-c-sharp. My guess is that perhaps the SSL is not allowing you to use that. What error do you get? – Nir Dec 18 '12 at 13:29
  • See answer on this link, I believe it might help: http://stackoverflow.com/questions/13743293/webclient-downloadingstring-changing-url-requested/13743403#13743403 – Ivan Golović Dec 18 '12 at 13:30

1 Answers1

1

I've written this function for me some time ago, hope this helps

    private void POST(string url, string data)
    {
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
        req.Method = "POST";
        req.Headers.Add(HttpRequestHeader.AcceptLanguage, "de-DE,de;q=0.8,en-US;q=0.7,en;q=0.3");

        req.Timeout = req.ReadWriteTimeout = 15000;

        ASCIIEncoding encoding = new ASCIIEncoding();
        byte[] dataBytes = encoding.GetBytes(data);
        req.ContentLength = dataBytes.Length;
        Stream stream = req.GetRequestStream();
        stream.Write(dataBytes, 0, dataBytes.Length);
        stream.Close();

        req.GetResponse();
    }
VladL
  • 12,769
  • 10
  • 63
  • 83