REST API communication through LUA code

I’m a beginner in Lua just started it. I was trying to call a restapi using lua but ,I’m facing issues 

[lua]

local headers = {}
headers[“Content-Type”] = “application/json”
headers[“X-API-Key”] = “u0X9q5qPvJ42ljksahdshdjsacmMlrU8jaP2g1O”
local body = “testfromLua”
local params = {}
params.headers = headers

params.body = body
network.request("https://“Sample API Url”, “POST”, networkListener, params)

[/lua]

The error is

attempt to index local 'network' (a nil value)

so what could be the problem? 

Thank you.

Hi @srotti and welcome to the Corona Labs community forums?

Are you using straight up Lua or are you using Corona?

network.* are Corona API"s and are not something that’s included with Lua.

Rob

Thanks @Rob but how do I use Corona API’s inside Lua, can I get some procedure about it. It would be helpful.

You can’t. Corona uses Lua, Lua doesn’t use Corona. Corona isn’t a library of Lua APIs. Corona is an Engine/Framework to build apps in that happens to use Lua as its scripting language. You would have to use Corona to build your applications.

Rob

Hi @srotti and welcome to the Corona Labs community forums?

Are you using straight up Lua or are you using Corona?

network.* are Corona API"s and are not something that’s included with Lua.

Rob

Thanks @Rob but how do I use Corona API’s inside Lua, can I get some procedure about it. It would be helpful.

You can’t. Corona uses Lua, Lua doesn’t use Corona. Corona isn’t a library of Lua APIs. Corona is an Engine/Framework to build apps in that happens to use Lua as its scripting language. You would have to use Corona to build your applications.

Rob