Lua
Lua
Aruba Fatturazione Elettronica CreateTransmissionRequest
See more Aruba Fatturazione Examples
Creation of a new request for the transmission of "Financial Communications" (single file transmission request).Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- Implements the following CURL command:
-- curl -X POST https://auth.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequest \
-- -H "Accept: application/json" \
-- -H "Content-Type: application/json;charset=UTF-8" \
-- -d '{
-- "userName" : "ARUBA0000",
-- "password" : "ArubaPwd",
-- "userID" : "ARUBA0000",
-- "comunicationType" : "LI",
-- "dataFile" : "dGVzdA=="
-- }'
-- Use the following online tool to generate HTTP code from a CURL command
-- Convert a cURL Command to HTTP Source Code
-- Use this online tool to generate code from sample JSON:
-- Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "userName": "ARUBA0000",
-- "password": "ArubaPwd",
-- "userID": "ARUBA0000",
-- "comunicationType": "LI",
-- "dataFile": "dGVzdA=="
-- }
-- The dataFile field must contain an xml document which conforms to the Revenue Agency specifications.
-- The document must be Base64 codified and contain a CADES-based electronic signature.
local sbSignedXml = chilkat.StringBuilder.new()
local success = sbSignedXml:load_file("qa_data/aruba/sampleXmlDoc.xml", "utf-8")
local json = chilkat.JsonObject.new()
json:update_string("userName", "ARUBA0000")
json:update_string("password", "ArubaPwd")
json:update_string("userID", "ARUBA0000")
json:update_string("comunicationType", "LI")
json:update_string("dataFile", sbSignedXml:get_encoded("base64", "utf-8"))
http:set_request_header("Content-Type", "application/json;charset=UTF-8")
http:set_request_header("Accept", "application/json")
local resp = chilkat.HttpResponse.new()
success = http:http_json("POST", "https://ws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequest", json, "application/json", resp)
if not success then
print(http.last_error_text)
return
end
local sbResponseBody = chilkat.StringBuilder.new()
resp:get_body_sb(sbResponseBody)
local jResp = chilkat.JsonObject.new()
jResp:load_sb(sbResponseBody)
jResp.emit_compact = false
print("Response Body:")
print(jResp:emit())
local respStatusCode = resp.status_code
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
print("Response Header:")
print(resp.header)
print("Failed.")
return
end
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "errorCode": "",
-- "errorDescription": "",
-- "requestID": "UICBY9QDLUOXQ72U"
-- }
-- Sample code for parsing the JSON response...
-- Use the following online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON
local errorCode = jResp:string_of("errorCode")
local errorDescription = jResp:string_of("errorDescription")
local requestID = jResp:string_of("requestID")