HTTP Request with body - Printable Version +- Logic Machine 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: HTTP Request with body (/showthread.php?tid=2538) |
HTTP Request with body - JoseJimenez94 - 23.03.2020 Hi everyone, I'm doing a little script to make a post request to an API. The form that this request should take is attached in the image. My code in LUA is: Code: require 'ltn12' Code: * arg: 1 I know I also have to enter a request body for the request to be complete, but when i try to enter it in the script i don't get any log. I've been looking in the help section of LUA, but i can't get it out. Somebody can help me? RE: HTTP Request with body - Joep - 23.03.2020 Here's an example i use for a Dutch weather API with JSON. This might help you. --Source: http://weerlive.nl/delen.php city = 'Amsterdam' --Vul hier de plaatsnaam in. require('ssl.https') require('json') data = ssl.https.request('http://weerlive.nl/api/json-10min.php?locatie=' ..city) datatable = json.pdecode(data) datatable = datatable['liveweer'][1] log(datatable) city = datatable.plaats log('Plaats: ' ..city) RE: HTTP Request with body - admin - 23.03.2020 You need to provide content-length header and source string (which can be empty). See this post for an example: https://forum.logicmachine.net/showthread.php?tid=1786&pid=11098#pid11098 |