Not sure if it is a duplicate question. A good function GetHTTPResult is already available from the link. You need to just pass the url for the GET request to fetch the data. For POST request (this function will not work), you need to make a POST request with postdata.
Also there is a sample for XMLHttpRequest at link
Function GetHTTPResult(sURL As String) As String Dim XMLHTTP As Variant, sResult As String Set XMLHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") XMLHTTP.Open "GET", sURL, False XMLHTTP.Send Debug.Print "Status: " & XMLHTTP.Status & " - " & XMLHTTP.StatusText sResult = XMLHTTP.ResponseText Debug.Print "Length of response: " & Len(sResult) Set XMLHTTP = Nothing GetHTTPResult = sResult End Function