https request to a server with a sefl-signed certificate

I am using network.request to try to talk to a server, via https POST, with a self signed certificate. What kind of response should I be expecting?

I have the headers and payload set to what the server should be expecting based on their documentation. Here is the code I have handling the event:

[lua]local function networkListener( event )  
 print( "listener start" );  
 if ( event.isError ) then  
 myText.text = "Login Failed!!"  
 print( "Network error!")  
 for key , value in pairs(event) do  
 print("Key " .. key .. " value " .. tostring(value))  
 end  
 else  
 myText.text = "Login Successful!"  
 print ( "RESPONSE: " .. event.response )  
 end  
 print( "listener end" );  
end[/lua]  

The output I get from that is:
[text]
listener start
Netowrk Error!
Key isError value true
Key url value —the url—
Key name value networkRequest
Key response value
listener end
[/text]

So, essentially, I’m not getting any indicator from the server as to what is wrong. Not sure if its because of the self-signed certificate or whether something else is wrong.

The other thing that is somewhat confusing is that based off of the networkRequest events I would expect that there is also event values for status, but that comes up nil and crashes if I try to reference it…

Any help is greatly appreciated.
Thanks! [import]uid: 159173 topic_id: 32864 reply_id: 332864[/import]

Can you show us your network.request call including how you’re setting up your params?

[import]uid: 19626 topic_id: 32864 reply_id: 130621[/import]

Here it is… Keep in mind I’ve removed the address I’m trying to touch, and changed the username/password I’m sending in the payload.

[code]
[lua]–HTTP Payload
postData = ‘{“user”:{“username”:“user”, “password”:"********"}}’
–HTTP header
tmpHeader = ‘{content-type=[application/json;charset=UTF-8], host=[localhost:8080], Content-Length=[’ … string.len(postData) …’], user-agent=[Jakarta Commons-HttpClient/3.1], Content-Type=[application/json;charset=UTF-8]}’

local params = {}
params.headers = tmpHeader
params.body = postData

network.request( ‘’, ‘POST’, networkListener, params )[/lua]
[/code] [import]uid: 159173 topic_id: 32864 reply_id: 130628[/import]

Can you show us your network.request call including how you’re setting up your params?

[import]uid: 19626 topic_id: 32864 reply_id: 130621[/import]

Here it is… Keep in mind I’ve removed the address I’m trying to touch, and changed the username/password I’m sending in the payload.

[code]
[lua]–HTTP Payload
postData = ‘{“user”:{“username”:“user”, “password”:"********"}}’
–HTTP header
tmpHeader = ‘{content-type=[application/json;charset=UTF-8], host=[localhost:8080], Content-Length=[’ … string.len(postData) …’], user-agent=[Jakarta Commons-HttpClient/3.1], Content-Type=[application/json;charset=UTF-8]}’

local params = {}
params.headers = tmpHeader
params.body = postData

network.request( ‘’, ‘POST’, networkListener, params )[/lua]
[/code] [import]uid: 159173 topic_id: 32864 reply_id: 130628[/import]

I think the problem is with how your passing headers and data to the server.

If you look at the documentation: http://docs.coronalabs.com/api/library/network/request.html

Your post data should be a URL encoded string like var=data&var2=data&var3=data and you’re passing what looks like JSON data instead.

Also for the headers, its expecting a Lua array where the key is the left side of the header parameter and the right size is the value:

headers["Content-Type"] = "application/json"  
headers["Accept-Language"] = "en-US"  

instead of passing in a string of what would be a table. I think on the headers if you just took off the outside single quotes, it probably would work out correctly for the headers. [import]uid: 19626 topic_id: 32864 reply_id: 130635[/import]

I had tried the headers as an array, but that didn’t work either, so I was trying things. I did find out a few other things this afternoon… There is a database that this path I’m trying to access uses, and it isn’t running at the moment. Thus I think this might be the key.

But I’ve also gotten indicattions that this company that develops the hardware I’m trying to access is notorious about not making their documentation correct and not testing the interfaces they provide… Unfortunately quite a few things to track down.

One question though… In this case, why is the event.status and event.response essentially empty? I had half expected that those would give me some codes or something to indicate what the issue was?

I appreciate the guidance.
Thank you! [import]uid: 159173 topic_id: 32864 reply_id: 130638[/import]

I think the problem is with how your passing headers and data to the server.

If you look at the documentation: http://docs.coronalabs.com/api/library/network/request.html

Your post data should be a URL encoded string like var=data&var2=data&var3=data and you’re passing what looks like JSON data instead.

Also for the headers, its expecting a Lua array where the key is the left side of the header parameter and the right size is the value:

headers["Content-Type"] = "application/json"  
headers["Accept-Language"] = "en-US"  

instead of passing in a string of what would be a table. I think on the headers if you just took off the outside single quotes, it probably would work out correctly for the headers. [import]uid: 19626 topic_id: 32864 reply_id: 130635[/import]

I had tried the headers as an array, but that didn’t work either, so I was trying things. I did find out a few other things this afternoon… There is a database that this path I’m trying to access uses, and it isn’t running at the moment. Thus I think this might be the key.

But I’ve also gotten indicattions that this company that develops the hardware I’m trying to access is notorious about not making their documentation correct and not testing the interfaces they provide… Unfortunately quite a few things to track down.

One question though… In this case, why is the event.status and event.response essentially empty? I had half expected that those would give me some codes or something to indicate what the issue was?

I appreciate the guidance.
Thank you! [import]uid: 159173 topic_id: 32864 reply_id: 130638[/import]