rest_req

mail@pastecode.io avatar
unknown
vbscript
a year ago
735 B
4
Indexable
Sub MakeRESTRequest()
    Dim xhr As Object
    Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    
    Dim url As String
    url = "https://api.example.com/data" ' Replace with your API endpoint
    
    ' Open a GET request to the URL
    xhr.Open "GET", url, False
    xhr.setRequestHeader "Content-Type", "application/json"
    
    ' Send the request
    xhr.send ""
    
    ' Handle the response
    If xhr.Status = 200 Then
        ' Successful response
        Debug.Print xhr.responseText ' You can process the response here
    Else
        ' Error handling
        Debug.Print "Request failed. Status code: " & xhr.Status
        Debug.Print "Response: " & xhr.responseText
    End If
    
    Set xhr = Nothing
End Sub