This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

REST with JSON
#1
Hi,

what is the better way to send some JSON values to a REST server ?

Something about this ?


https = require('ssl.https')
url = 'http://IP_MACHINE/url'
body = [[{
"timestamp": NOW(),
"meter": grp.getvalue('32/2/4')
}]]
resp = {}
res, code, hdrs, stat = https.request({
  url = url,
  method = 'POST',
  headers = {
    ['Content-Type'] = 'application/json',
    ['Content-Length'] = #body,
  },
  source = ltn12.source.string(body),
  sink = ltn12.sink.table(resp),
})
resp = table.concat(resp)
log(res, code, hdrs, stat, resp)



How can I use NOW() and grp.getvalue inside of the JSON ?
KNX Advanced Partner + Tutor
Reply


Messages In This Thread
REST with JSON - by toujour - 05.10.2024, 08:49
RE: REST with JSON - by CristianAgata - 05.10.2024, 09:18
RE: REST with JSON - by toujour - 10.10.2024, 08:08

Forum Jump: