Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
lbell
Visitor

addheader? rourltransfer

Can somebody explain to me what the addheader() does and how to use it?
0 Kudos
2 REPLIES 2
RokuJoel
Binge Watcher

Re: addheader? rourltransfer

Addheader lets you add a header key/value pair to the data send with an HTTP request. Here's an example:

So:


function GetData() as object
xfer=createobject("roURLtransfer")
xfer.SetUrl("https://api.myserver.com/data")
xfer.SetCertificatesFile("common:/certs/ca-bundle.crt")
xfer.InitClientCertificates()
ba = CreateObject("roByteArray")
ba.FromAsciiString("me@myemailaddress.com":"myAPIKeyblahblah")
xfer.AddHeader("Authorization", "Basic " + ba.ToBase64String())
xfer.AddHeader("X-API-VERSION","3")
results=xfer.GetToString()
'print results
data=parsejson(results)
return data
end function
lbell
Visitor

Re: addheader? rourltransfer

Ahhh, makes sense. Thanks(:
0 Kudos