Archived Forum Post

Index of archived forum posts

Question:

HTTP using Query String (GET) or POST

Mar 03 '14 at 10:24

I’ve been using the control for SOAP communications and it works great.

Now the company I’m interfacing with wants me to expand the application to fetch their website .aspx in a browser using a query string or post (see below) and process the response. This is totally new territory for me. Can this be done within the HTTP control?

Query String

https://test.something.com/xyz/abc.aspx?key=111111-22222-33333

FORM POST

<form id="Form1" method="post" action="https://test.something.com/xyz/abc.aspx">
        <input type="text" name="key" id="xkey" value="111111-22222-33333" />
        <input type="submit" value="Submit" />
</form>


Answer

Yes, this is very simple. To send a GET and get the response, just use QuickGetStr:

string responseBody = http.QuickGetStr("https://test.something.com/xyz/abc.aspx?key=111111-22222-33333");
This will automatically use SSL/TLS because of the "https://" in the URL.

You may instead send a POST (equivalent to the FORM above) like this:

Chilkat.HttpRequest req = new Chilkat.HttpRequest();

req.AddParam("key","111111-22222-33333");

Chilkat.HttpResponse resp = null; resp = http.PostUrlEncoded("https://test.something.com/xyz/abc.aspx",req); if (resp == null ) { textBox1.Text += http.LastErrorText + "rn"; return; }

string reponseBody = resp.BodyStr;


Answer

This doesn't invoke the default browser does it? That is what I need to do, pop up the web page, fill out the web form and return the html.