Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
lbell
Level 7

addheader? rourltransfer

Can somebody explain to me what the addheader() does and how to use it?
0 Kudos
2 Replies
Roku Employee
Roku Employee

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
0 Kudos
lbell
Level 7

Re: addheader? rourltransfer

Ahhh, makes sense. Thanks(:
0 Kudos