Search code examples
restweb-servicesvb6

Get/post to RESTful web service


I need to do some GETing and POSTing to a RESTful web service from VB6. What is the best and simplest way to do that?


Solution

  • You'll need to add a reference to the MSXML library:

    Dim sUrl As String
    Dim response As String
    Dim xmlhttp
    
    Set sUrl = "http://my.domain.com/service/operation/param"
    
    Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
    xmlhttp.open "POST", sURL, False
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    xmlhttp.send()
    
    Dim response As String = xmlhttp.responseText
    
    Set xmlhttp = Nothing