Post Data

  • Thread starter Thread starter Chris Cairns
  • Start date Start date
C

Chris Cairns

I need to be able to initiate a HTTP POST to a server and the server will
respond with a text string. How do I initiate this in access and collect
the string?

I was able to do the post via a simple web page. I created a html form with
a submit button and it does return the string. I just need to be able to
automate this in access so it will create, submit and retreive the response
without the user ever having to see the resulting input or response page.
 
Chris Cairns said:
I need to be able to initiate a HTTP POST to a server and the server will
respond with a text string. How do I initiate this in access and collect
the string?

I was able to do the post via a simple web page. I created a html form with
a submit button and it does return the string. I just need to be able to
automate this in access so it will create, submit and retreive the response
without the user ever having to see the resulting input or response page.

The MSXML libraries have tools for sending HTTPRequests and handling the response
from the server. There are several "flavors" of this library that don't always
interchange easily, but most of the differences have to do with the XML
functionality. You should be able to use late binding for the basic HTTPRequest
calls without having to be too concerned with the installed library version. Below
is a basic example:

Dim oHttpPost As Object
Set oHttpPost = CreateObject("Microsoft.XMLHTTP")

oHttpPost.Open "POST", "Your URL", False
oHttpPost.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oHttpPost.send (YourDataVariable)

'Process response from server
If oHttpPost.Status < 300 Then 'Response is OK
SomeVariable = oHttpPost.responseText
 
Back
Top