in VBA, could we use VBA excel to call API from Prediction DataRobot?
Does anyone know about the template script? Thanks
in VBA, could we use VBA excel to call API from Prediction DataRobot?
Does anyone know about the template script? Thanks
Yes, you can send API requests using VBA! Here is the very basic function that I use to do simple API requests. It works for me with GET requests on most websites. For POST or PUT, you will need to know their specific URL Scheme and Body text format.
Private Function XML_API( _
ByVal URL As String, _
ByVal Action As String, _
Optional Body As String = "") As String
Dim http As Object
Set http = CreateObject("MSXML2.XMLHTTP.6.0")
http.Open Action, URL, False
'Default Headers
http.setRequestHeader "Content-Type", "application/xml"
''''''''''''''''
'Send
If Body <> "" Then
http.Send CVar(Body)
Else
http.Send
End If
'Interpret Response
If http.Status = 200 And Action <> "GET" Then
XML_API = "Successfully Sent!"
Else
If http.Status <> 200 And http.responsetext = "" Then
XML_API = http.statustext
Else
XML_API = http.responsetext
End If
End If
End Function