I am testing 2 codes written in Excel VBA. The first function Get_Instruments returns all the instruments listed on an exchange. It works fine. However, the other function, OHLC_1_min data does not work. It returns an error "authorization value should atleast be `api_key`:`access_token`" (Image 3). Please tell me where am I going wrong. Please notice that I am referencing the correct cell where apikey and access token is stored. If that was the issue, Get_Instruments would not work at all.
Function Get_Instruments(exc As String) As Boolean
Dim acc_token As String, respo As String, apikey As String, HTTPReq As Variant, endpoint As String apikey = ThisWorkbook.Worksheets("Sheet6").Cells(2, 7).Value acc_token = ThisWorkbook.Worksheets("Sheet6").Cells(9, 7).Value Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1") endpoint = "https://api.kite.trade/instruments/" & exc
' Dim JSON_Data As String, pewpew() As Variant ' JSON_Data = respo ' Set dic = ParseJSON(JSON_Data) ' ' pewpew = dic("obj.data.candles") ' Dim i As Variant ' For i = LBound(pewpew) To UBound(pewpew) Step 1 ' ThisWorkbook.Worksheets("Sheet7").Cells(1 + i, 1).Value = pewpew(i) ' Next i
Dim exitcheck As Boolean exitcheck = True OHLC_1_min = exitcheck
@sujith you are right. I have resolved the issue. Base64 encoding is not required. I simply had to do encode_str = apikey & ":" & acc_token and that was it.
Maybe don't do Base64 encoding while fetching historical data.
PS: Do you have add-on historical data subscription?
encode_str = apikey & ":" & acc_token
and that was it.
Yes, I have Historical data subscription.