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?
Check documentation for getToString. You can't get response code with synchronous call. Use asyncGetToString instead.