Skip to content

Instantly share code, notes, and snippets.

@sudiptamondal
Created February 25, 2020 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudiptamondal/8514ceb8ce44bfcd8690145125b833d5 to your computer and use it in GitHub Desktop.
Save sudiptamondal/8514ceb8ce44bfcd8690145125b833d5 to your computer and use it in GitHub Desktop.
Code Snippet to send GET Request via function in Excel Macro
Private Sub FetchData()
Dim objRequest As Object, strUrl As String, blnAsync As Boolean, strResponse As String
Dim jsonObject As Object, item As Variant
Set objRequest = CreateObject("MSXML2.XMLHTTP")
strUrl = "<URL_GOES_HERE>"
blnAsync = True
With objRequest
.Open "GET", strUrl, blnAsync
.setRequestHeader "Content-Type", "application/json"
.Send
While objRequest.readyState <> 4
DoEvents
Wend
strResponse = .ResponseText
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment