Answer the question
In order to leave comments, you need to log in
How to make post request in lua?
How to make a post request in lua?
It doesn't matter which library you use.
If not difficult, give at least 1 example. For what I find on the Internet does not work (probably my hands are from the wrong place)
Answer the question
In order to leave comments, you need to log in
Everything works fine right from the examples googled from the Internet. You need the luasocket library.
local http = require "socket.http"
local ltn12 = require "ltn12"
local reqbody = "{post body}"
local respbody = {} -- for the response body
local result, respcode, respheaders, respstatus = http.request {
method = "POST",
url = "https://httpbin.org/post",
source = ltn12.source.string(reqbody),
headers = {
["content-type"] = "text/plain",
["content-length"] = tostring(#reqbody)
},
sink = ltn12.sink.table(respbody)
}
-- get body as string by concatenating table filled by sink
respbody = table.concat(respbody)
print (result)
print (respcode)
print (respheaders)
print (respstatus)
print (respbody)
Two queries are better, because if you have a many-to-many relationship, you will have duplicate information about the room.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question