Sunday, October 25, 2009

Calling a REST Service from VB

I did not have much luck calling the Yahoo REST service, so I created my own web service using the MyEclipse tutorial and tested it out. The VB code to call the REST service is as follows:

Sub Macro1()

url = ""

Dim HttpReq As Object
Set HttpReq = New WinHttpRequest

HttpReq.Open "GET", 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 the next challange is to get the Microsoft XML parser working.

No comments:

Post a Comment

VBA Excel to Double Click change to checkmark or x

 Note that to do this, you need to set the font of the affected cells to Winding 2 first: 1 2 3 4 5 6 7 8 9 10 11 12 Private Sub Worksheet...