views:

220

answers:

0

I'm using WinHttp to access an URL, say "http://server/application?id=abc"

When I try to URL from Explorer, I get an HTML table with lots of info. However when I try from Excel VBA like this:

ht.Open "POST", "http://server/application?id=abc", False ht.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" ht.SetRequestHeader "Content-Type", "multipart/form-data; " ht.Send

I obtain the following ht.ResponseText:

<script language="javascript" type="">
  function submitForm() {
    document.forma.submit();
  }
</script>
<html>
  <body bgcolor="#FFFFFF" onload="submitForm()">
    <font size="20" color="blue">Loading. Please wait.</font>
<form NAME="form1" ACTION="dispatch" METHOD="post">
  <INPUT TYPE="hidden" name="action" value="response">
  <INPUT TYPE="hidden" name="user_id" value="user">
  </FORM>
 </body>
</html>

So it looks like it sets a couple of hidden parameters on a form and then submits itself upon load.

I've tried various things to no avail, for example adding those hidden fields like this:

Dim login As String
login = "action=response&user_id=user"

and then ht.Send login

But nothing seems to work!

How can I construct the WinHttp send request to follow up this redirection in order to obtain the data behind the redirection??

Thanks in advance!