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 ?
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