LogicMachine Forum
curl to post value to TRMNL api - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: curl to post value to TRMNL api (/showthread.php?tid=6463)



curl to post value to TRMNL api - Pierre - 11.06.2026

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:
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(resp

i have this error: Must be nested inside a merge_variables payload object
could you can help me please.


RE: curl to post value to TRMNL api - admin - 11.06.2026

Try this:
Code:
http = require('socket.http') json = require('json') url = 'https://trmnl.com/api/custom_plugins/xxxxxxxxxxxxxxxxxxxxxxxxxxx' body = json.encode({   merge_variables = {     text = 'Test',     author = 'Pierre',   } }) resp, code, headers = http.request({   url = url,   method = 'POST',   body = body,   headers = {     ['Content-Type'] = 'application/json',   } }) resp = json.pdecode(resp) log(resp)



RE: curl to post value to TRMNL api - Pierre - 11.06.2026

perfect thanks a lot