This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

HTTP Request with body
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:
require 'ltn12'
http = require('socket.http')

http.TIMEOUT = 5

local url = ''
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)
* arg: 1
  * number: 500
* arg: 2
  * table:
    * 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?

Attached Files Image(s)
Here's an example i use for a Dutch weather API with JSON. This might help you.

city = 'Amsterdam' --Vul hier de plaatsnaam in.


data = ssl.https.request(''
datatable = json.pdecode(data)

datatable = datatable['liveweer'][1]

city = datatable.plaats
log('Plaats: '
You need to provide content-length header and source string (which can be empty). See this post for an example:

Forum Jump: