lala_Hae_dong
New Member
- Joined
- Apr 13, 2023
- Messages
- 7
- Office Version
- 365
- Platform
- Windows
So far I have been using Postman to GET data with our bearer token. I need to get this data into Excel. So far what we've done is download the .json using postman, convert the .json to .xml and open the file with Excel. Can I use VBA to pull data from the web that requires bearer token authentication and also can I automatically convert the .json data to .xml?
I have done some research and found a code
Sub GetData()
Dim hReq As Object, Json As Dictionary
Dim sht As Worksheet
Dim authKey As String
authKey = {my token key}
Set sht = Sheet1
Dim strUrl As String
strUrl = "https://myurl"
Set hReq = CreateObject("MSXML2.XMLHTTP")
With hReq
.Open "GET", strUrl, False
.SetRequestHeader "Authorization", "Bearer " & authKey
.Send
End With
Dim response As String
response = hReq.ResponseText
MsgBox response
End Sub
But whenever I insert the authKey bearer token I have it gives an error.
I have done some research and found a code
Sub GetData()
Dim hReq As Object, Json As Dictionary
Dim sht As Worksheet
Dim authKey As String
authKey = {my token key}
Set sht = Sheet1
Dim strUrl As String
strUrl = "https://myurl"
Set hReq = CreateObject("MSXML2.XMLHTTP")
With hReq
.Open "GET", strUrl, False
.SetRequestHeader "Authorization", "Bearer " & authKey
.Send
End With
Dim response As String
response = hReq.ResponseText
MsgBox response
End Sub
But whenever I insert the authKey bearer token I have it gives an error.