Skip to content

Instantly share code, notes, and snippets.

@jjfajardo
Forked from mikekatz/ReadLuaTableFromKinvey.lua
Last active August 29, 2015 14:23
Show Gist options
  • Save jjfajardo/e320166f1a9ec82ece0d to your computer and use it in GitHub Desktop.
Save jjfajardo/e320166f1a9ec82ece0d to your computer and use it in GitHub Desktop.
-- 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