How can i do a http request to firebase?
Posted: Mon Feb 06, 2023 2:22 pm
I'm trying make a http request to my firebase realtime database using lua but don't work and i don't know why. This is the code i use:
The "code" returns me a "closed". I do the same with Postman and works.
Those are the only modules i use because the others modules needs install luarocks in windows and i tried to install it but don't works, so i used those modules but if another is better please tell me. But i think i'm not setting well something or i miss something. Please help me :c
Code: Select all
local http = require("socket.http")
local json = require "json"
local body, code, headers, status = http.request {
method = "POST",
url = "https://test-d4421-default-rtdb.firebaseio.com/data.json",
headers = {
["Content-Type"] = "text/plain",
["Accept-Encoding"] = "gzip",
["Connection"] = "keep-alive",
["User-Agent"] = "love2d",
["Accept"] = "*/*"
},
source = ltn12.source.string(json.encode({nombres = "pablo"}))
}
print(code) -- closed
print(body) -- nil
Those are the only modules i use because the others modules needs install luarocks in windows and i tried to install it but don't works, so i used those modules but if another is better please tell me. But i think i'm not setting well something or i miss something. Please help me :c