23.03.2020, 12:52
(This post was last modified: 23.03.2020, 12:53 by JoseJimenez94.)
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:
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?
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'
require('json')
http = require('socket.http')
http.TIMEOUT = 5
local url = 'http://192.168.0.163:3000/api/v1/hvac'
local response_body = {}
local body, code, hdrs, stat = http.request
{
url = url;
method = "POST";
headers =
{
["Content-Type"] = "application/json";
};
sink = ltn12.sink.table(response_body);
}
log ( code, response_body)
Code:
* arg: 1
* number: 500
* arg: 2
* table:
[1]
* string: {"errors":[{"error":"request malformed"}]}
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?