BRIGHTSCRIPT: ERROR: ParseJSON: Data is empty:
request=CreateObject("roUrlTransfer")
request.SetURL("https://apis.someserver.com/glist")
request.AddHeader("Authorization", "Basic")
request.AddHeader("app_key","username")
request.AddHeader("app_secret","password")
response = ParseJson(request.GetToString())
function AuthSerial()
serial = GetDeviceESN()
request = CreateObject("roUrlTransfer")
ba = CreateObject("roByteArray")
ba.FromAsciiString(serial)
request.SetCertificatesFile("pkg:/certs/certs.crt")
request.InitClientCertificates()
request.AddHeader("X-Content", ba.ToBase64String())
request.SetUrl("https://apis.someserver.com/dato.php")
html = request.GetToString()
data = html.Trim()
json = ParseJSON(data)
return json
end function
dato= AuthSerial()
user = dato.user
pass = dato.pass
"dreamer2057" wrote:
You need to debug your code to view more details about errors. It might be some https issues with security check.
Take a look: http://forums.roku.com/viewtopic.php?f=34&t=92989
"belltown" wrote:
Another thing that might help you is to call event.GetFailureReason() to get a more descriptive reason for the error.
"dreamer2057" wrote:
dd = event.GetString()
code = event.GetResponseCode()
"dreamer2057" wrote:"belltown" wrote:
Another thing that might help you is to call event.GetFailureReason() to get a more descriptive reason for the error."dreamer2057" wrote:
dd = event.GetString()
code = event.GetResponseCode()
and 'print' them
For example..
Function TestHttps() as Dynamic
print "HTTPS STARTED"
url = " ... enter url "
timeout = 1500
num_retries = 1
http = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
http.SetUrl(url)
http.SetMessagePort(port)
http.SetRequest("POST")
http.AddHeader("Content-Type", "application/json")
http.AddHeader("X-Roku-Reserved-Dev-Id")
http.SetCertificatesFile("pkg:/source/certificates/cafile.pem")
http.EnableHostVerification(true)
http.EnablePeerVerification(true)
http.InitClientCertificates()
http.RetainBodyOnError(true)
while num_retries > 0
if (http.AsyncPostFromString(""))
event = wait(timeout, http.GetPort())
print event
if type(event) = "roUrlEvent"
dd = event.GetString()
code = event.GetResponseCode()
print code
if code = 200
print "HTTPS data:" + dd
print "HTTPS code:" + ToString(code)
return dd
else
print "HTTPS data:" + dd
print "HTTPS code:" + ToString(code)
timeout = timeout * 2
num_retries = num_retries - 1
print "HTTPS New try: " + ToString(num_retries)
endif
else
timeout = timeout * 2
num_retries = num_retries - 1
print "HTTPS New try: " + ToString(num_retries)
endif
endif
end while
print "HTTPS FINISHED"
End Function
http.SetCertificatesFile("pkg:/source/certificates/cafile.pem")
http.SetCertificatesFile ("common:/certs/ca-bundle.crt")
-77
error setting certificate verify locations:
CAfile: /tmp/plugin/BEAAAA8IJGIU/pkg:/certs/cacert.crt
CApath: none
http = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
http.SetUrl("https://someserver/playlist")
http.SetMessagePort(port)
ba = CreateObject("roByteArray")
ba.FromAsciiString("username:password")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())
http.AddHeader("Content-Type", "application/json")
'http.AddHeader("X-Roku-Reserved-Dev-Id", "")
http.SetCertificatesFile("pkg:/certs/cacert.crt")
http.InitClientCertificates()
http.RetainBodyOnError(true)
num_tries = 1
while num_tries > 0
if (http.AsyncGetToString()) 'AsyncPostFromString("")
event = wait(0, http.GetPort())
if type(event) = "roUrlEvent"
dd = event.GetString()
code = event.GetResponseCode()
st = event.GetFailureReason()
print code; "--------"
print st; "&&&&&&&&&&&"
num_tries = num_tries -1
end if
end if
end while