VBA Get Send Error - Additional Info

  • I have code that is stopping on the hReq.send line. I have two filters required in the send body, StartDate and EndDate. Can anyone see my mistake?

    The documnetation shows the boidy should say:

    "filters": {
    "startDate": "2018-04-01",
    "endDate": "2018-04-23",
    "aggregation": "day"

    This is my original code:

    Sub Index_Earnings()

    Dim result2 As String
    Dim myurl As String
    Dim StartDate As Date
    Dim EndDate As Date
    Dim StartDateF As String
    Dim EndDateF As String
    Dim winHttpReq As Object
    Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")

    With Worksheets("API Calls")
    StartDate = Sheets("Index API").Range("B10").Value
    StartDateF = Format(StartDate, "YYYY-MM-DD")
    EndDate = Sheets("Index API").Range("B11").Value
    EndDateF = Format(EndDate, "YYYY-MM-DD")
    End With

    myurl = "https://api01.indexexchange.com/api/publishers/stats/earnings/open"

    winHttpReq.Open "Get", myurl, False
    winHttpReq.SetRequestHeader "Authorization", "Bearer X"
    winHttpReq.SetRequestHeader "Cache-Control", "no-cache"
    winHttpReq.Send (postdata)
    hReq.Send ("{""startDate"":" & """" & StartDateF & """" & ",""endDate"":" & """" & EndDateF & """" & "}")

    result2 = winHttpReq.responseText
    Sheets("Index API").Range("B6") = result2

    It freezes on the hReg.send.

    I modified it to be:

    hReq.Send ({""filters"":"{""startDate"":" & """" & StartDateF & """" & ",""endDate"":" & """" & EndDateF & """" & "}")

    Can some help with my syntax and formating?

Log in to reply

Looks like your connection to Codingislove Forum was lost, please wait while we try to reconnect.