Lua
Lua
POST application/json HTTPS Request
See more HTTP Examples
Demonstrates how to send an HTTPS POST where the request body and response body both have the application/json Content-Type. Also demonstrates how to add a few custom headers to the request.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code
local http = chilkat.Http.new()
-- Add a few custom headers.
http:set_request_header("Client-ID", "my_client_id")
http:set_request_header("Client-Token", "my_client_token")
http.accept = "application/json"
local url = "https://api.fiscallog.eu/sign/v1"
local jsonRequestBody = "{ .... }"
local resp = chilkat.HttpResponse.new()
local success = http:http_str("POST", url, jsonRequestBody, "utf-8", "application/json", resp)
if not success then
print(http.last_error_text)
return
end
print("Response status code = " .. resp.status_code)
local jsonResponseStr = resp.body_str
print(jsonResponseStr)