Thursday, October 22, 2009

How to Post and Get from HTTP using VB6

Thanks to some help from Doc's Coding, I was able to get Microsoft Excel 2000 to do a GET request.

I had to add a reference by going to Tools|Reference, then select Microsoft winhttp service version 5.1

Then I added the following code:


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 22/10/2009 by John Hufnagel
'
url = "http://www.google.ca/"
postmydata = "variable=data&variable2=data2"
Dim HttpReq As Object

Set HttpReq = New WinHttpRequest

HttpReq.Open "POST", url, False
'or use GET instead of POST

HttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

HttpReq.send postmydata
'Note - if using GET set postmydata to ""

MsgBox (HttpReq.responseText)

End Sub

Now that I have the basic GET working, the next challange is to make a Yahoo! Web Service REST Call

No comments:

Post a Comment

JSP - Java Description

https://docs.oracle.com/javaee/5/tutorial/doc/bnair.html Install Java on the computer:  https://phoenixnap.com/kb/install-java-windows Insta...