I just posted my issue with HTTP GET Request using VBA, and I just got it working with the suggestion given to me in a previous post. I took the "Basic" out of the "SetRequestHeader" and I was able to see data. Since my data is in JSON format, I must request the data correctly and storage it to a text file.
In my code, I was setting P = JSON.parse(XMLHttpReq.responseText) being undefine, and what should I define JSON to be in this code??? I was not able to run it because of this issue.
Let me know if anyone see anything wrong too with this, or other suggestions!
I have added some VBA code below to handle the request.
Sub Test()
Dim sUrl As String, sAuth As String
Dim P As Object
Dim XMLHttpReq As MXXML2.ServerXMLHTTP
sUrl = "https://api.ngs.nfl.com/tracking/game/play?gameKey=57444&playId=51"
sAuth = "NGS AKIAIX2CQ7IEOKPOTKDQ:uNniaOp4jH8jcK9i/EtQhurlilc="
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", sUrl, False
.setRequestHeader "Authorization", "Basic " & sAuth
.send
If XMLHttpReq.ReadyState = 4 Then
If XMLHttpReq.Status = 200 Then
' Process the JSON response here
Debug.Print "200 received"
Set P = JSON.parse(XMLHttpReq.responseText)
Else
If XMLHttpReq.Status = 404 Then
' Handle it
End If
End If
Debug.Print .getAllResponseHeaders
End With
End Sub