I have a REST service and a method like this:
public void SaveData (Position pos)
{
…
}
How do i create that Position class in Corona and LUA for my REST call:
network.request( http://xx.xx.xx./SaveData/pos, “POST”, networkListener , params )
ISO
I have a REST service and a method like this:
public void SaveData (Position pos)
{
…
}
How do i create that Position class in Corona and LUA for my REST call:
network.request( http://xx.xx.xx./SaveData/pos, “POST”, networkListener , params )
ISO
It looks like your REST framework is Java? There is really no way to create and send a Java object via Lua.
Your best bet is to rely on passing JSON with data. But you would need to restructure your REST code.
Best.
local function networkListener( event )
if ( event.isError ) then
print( “Network error!”)
else
print ( "RESPONSE: " … event.response )
end
end
local t = {
[“Name”] = deviceId;
[“Longitude”] = currentLongitude;
[“Latitude”] = currentLatitude;
[“Teksti”] = “My position”;
}
local encoded = json.encode( t )
local headers = {}
headers[“Content-Type”] = “application/json”
local params = {}
params.headers = headers
params.body = encoded
network.request( “http://XXXXX.azurewebsites.net/api/YYYYY”, “POST”, networkListener, params )
This works.
ISO
It looks like your REST framework is Java? There is really no way to create and send a Java object via Lua.
Your best bet is to rely on passing JSON with data. But you would need to restructure your REST code.
Best.
local function networkListener( event )
if ( event.isError ) then
print( “Network error!”)
else
print ( "RESPONSE: " … event.response )
end
end
local t = {
[“Name”] = deviceId;
[“Longitude”] = currentLongitude;
[“Latitude”] = currentLatitude;
[“Teksti”] = “My position”;
}
local encoded = json.encode( t )
local headers = {}
headers[“Content-Type”] = “application/json”
local params = {}
params.headers = headers
params.body = encoded
network.request( “http://XXXXX.azurewebsites.net/api/YYYYY”, “POST”, networkListener, params )
This works.
ISO