3

I have this piece of code that gets and parses JSON from an HTTPS url:

Function GetJson(sUrl As String) As dynamic
    if sUrl = invalid return invalid
    httpGet = CreateObject("roUrlTransfer")
    httpGet.SetURL(sUrl)
    httpGet.EnableEncodings(true)
    httpGet.RetainBodyOnError(true)
    sData = httpGet.GetToString()
    if sData = "" 
        print "ERROR: " + sUrl + " : " + httpGet.GetFailureReason()
    end if

    data = ParseJson(sData)
    return data
End Function

sData is empty. How do I get the HTTP response code or error? httpGet.GetFailureReason() is always blank...

Turns out the fix was to add this, but I need to find out how to dump the the HTTP(s) error so I know what is going on

    httpGet.SetCertificatesFile("common:/certs/ca-bundle.crt")
    httpGet.InitClientCertificates()

Any idea?

rynop
  • 50,086
  • 26
  • 101
  • 112

1 Answers1

1

Check documentation for getToString. You can't get response code with synchronous call. Use asyncGetToString instead.

Eugene Smoliy
  • 934
  • 4
  • 9
  • 1
    It is unfortunate indeed. You can however use `GetToFile()` which will return the HTTP response code, as a way to avoid dealing with async gallimaufry – Nas Banov Nov 10 '16 at 22:02