在VBA中,是否可以使用VBA excel调用Prediction DataRobot中的应用程序接口?
有人知道模板脚本吗?谢谢
发布于 2021-04-26 21:13:20
可以,您可以使用VBA发送API请求!下面是我用来处理简单API请求的最基本的函数。它适用于我在大多数网站上的GET请求。对于POST或PUT,您需要知道其特定的URL方案和正文格式。
Public Function API( _
ByVal URL As String, _
ByVal Action As String, _
Optional Body As String = "") As String
'Action is GET, POST, PUT or DELETE
Dim http As Object
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
http.Open Action, URL, False
If Action <> "GET" Then http.SetRequestHeader "Content-Type", "application/json"
If Body <> "" Then
http.Send Body
Else
http.Send
End If
If http.Status = 200 And Action <> "GET" Then
API = "Successfully Sent!"
Else
If http.Status <> 200 And http.responsetext = "" Then
API = http.statustext
Else
API = http.responsetext
End If
End If
End Functionhttps://stackoverflow.com/questions/67265045
复制相似问题