Call an API Using ASP classic

0

I have an API that gives information about the NBA (scores, team name etc) and I have to make a call to this API to return the info and then I want to show that info on a page, but I must do it with asp classic and I'm a bit lost I have an idea of how to do it but I do not have the correct codes. Help me pls!

    <%
                        Dim http: Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
                        Dim url: url = "https://probasketballapi.com/teams"
                        Dim data: data = "https://probasketballapi.com/stats/teams"

                        With http
                          Call .Open("POST", url, False)
                          Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
                          Call .SetRequestHeader("X-Api-Key", "yourvalue")
                          Call .SetRequestHeader("X-Auth-Token", "yourvalue")
                          Call .Send(data)
                        End With

                        If Left(http.Status, 1) = 2 Then
                          'Request succeeded with a HTTP 2xx response, do something...
                        Else
                          'Output error
                          Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
                        End If
                        %>
    
asked by Mtac 19.04.2018 в 02:13
source

0 answers