11.06.2026, 06:41
Hello,
I want to send data to TRMNL server
this curl command is ok :
curl "https://trmnl.com/api/custom_plugins/xxxxxxxxxxxxxxxxxxxxxxxxxxx\
-H "Content-Type: application/json" \
-d '{"merge_variables": {"text":"Test", "author": "Pierre"}}' \
-X POST
but my lua code don't work:
i have this error: Must be nested inside a merge_variables payload object
could you can help me please.
I want to send data to TRMNL server
this curl command is ok :
curl "https://trmnl.com/api/custom_plugins/xxxxxxxxxxxxxxxxxxxxxxxxxxx\
-H "Content-Type: application/json" \
-d '{"merge_variables": {"text":"Test", "author": "Pierre"}}' \
-X POST
but my lua code don't work:
Code:
-- Load modules
https = require('ssl.https')
ltn12 = require('ltn12')
json = require('json')
body ='{"merge_variables": {"text":"Test", "author": "Pierre"}}'
resp = {}
body = json.encode(Body)
res, code, headers = https.request({
url = 'https://trmnl.com/api/custom_plugins/xxxxxxxxxxxxxxxxxxxxxxxxxxx',
method = 'POST',
source = ltn12.source.string(body),
sink = ltn12.sink.table(resp),
headers = {
['Content-Type'] = 'application/json',
['Content-Length'] = #body
}
})
-- handle feedback
resp = table.concat(resp)
resp = json.pdecode(resp)
log(respi have this error: Must be nested inside a merge_variables payload object
could you can help me please.