Skip to content

Instantly share code, notes, and snippets.

@mikekatz
Created June 8, 2012 15:51
Show Gist options
  • Save mikekatz/2896316 to your computer and use it in GitHub Desktop.
Save mikekatz/2896316 to your computer and use it in GitHub Desktop.
Save Lua Table To Kinvey - blog exmaple 2 - read
-- GET back the object to verify that we saved it
response = {}
save = ltn12.sink.table(response)
id = objAsTable["_id"] -- get the _id field from the object table
url = "https://baas.kinvey.com/appdata/KINVEY_APP_ID/testObjects/" .. id
h = {Authorization = "Basic " .. (mime.b64("KINVEY_APP_ID:KINVEY_APP_SECRET")), ["Content-Type"] = "application/json" }
ok, code, headers = http.request{url = url, headers = h, sink = save, redirect = true, method = "GET"}
print(code) -- success should be a 200
print(table.concat(response))
-- convert back to the JSON object
loadedTable = json.decode(response[1])
for k,v in pairs(loadedTable) do print(k,v) end
delete this gist
Comments are parsed with GitHub Flavored Markdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment