I’m trying to log on to a web service using a simple HTTP authorization using network.request() and i’m not having any luck. And I can’t seem to find a solution. The web service is a web based POS: http://docs.vendhq.com/intro.html and they use cURL as an example (Which I don’t know so it’s not helpful). But it does seem rather straight forward.
I’m editing the sample code to just see if I can get this part working:
local myText = display.newText("(Waiting for response)", 0, 0, native.systemFont, 16) myText.x = display.contentCenterX myText.y = 120 local function networkListener( event ) if ( event.isError ) then myText.text = "Network error!" else myText.text = "See Corona Terminal for response" print ( "RESPONSE: " .. event.response ) end end local headers = {} headers["Authorization"] = "username:password" headers["Accept"] = "application/json" local params = {} params.headers = headers -- Access Google over SSL: network.request( "https://companyName.vendhq.com/api/products", "GET", networkListener, params )
But it just gives me in the console: error: “API Auth required”
So i’m obviously not posting my log in credentials properly/ I’m I doing this wrong?