Lua
Lua
Aruba Fatturazione Elettronica Upload Invoice
See more Aruba Fatturazione Examples
This method must be used by the EO to send an invoice in XML format in accordance with AGID standards, but not yet digitally signed.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://ws.fatturazioneelettronica.aruba.it/services/invoice/upload \
-- -H "Accept: application/json" \
-- -H "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" \
-- -H "Content-Type: application/json;charset=UTF-8" \
-- -d '{
-- "dataFile" : "dGVzdA==",
-- "credential" : "",
-- "domain" : ""
-- }'
-- 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.
-- {
-- "dataFile": "dGVzdA==",
-- "credential": "",
-- "domain": ""
-- }
-- The dataFile field must contain an XML invoice not yet digitally signed.
local sbInvoiceXml = chilkat.StringBuilder.new()
local success = sbInvoiceXml:load_file("qa_data/aruba/invoice123.xml", "utf-8")
local json = chilkat.JsonObject.new()
json:update_string("dataFile", sbInvoiceXml:get_encoded("base64", "utf-8"))
json:update_string("credential", "")
json:update_string("domain", "")
http:set_request_header("Accept", "application/json")
-- Adds the "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" header.
http.auth_token = "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
http:set_request_header("Content-Type", "application/json;charset=UTF-8")
local resp = chilkat.HttpResponse.new()
success = http:http_json("POST", "https://ws.fatturazioneelettronica.aruba.it/services/invoice/upload", 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": "0000",
-- "errorDescription": "Operazione effettuata - 521e052902be7b879d41e0fd586f0e21",
-- "uploadFileName": "IT06491598644_zbvbd.xml.p7m"
-- }
-- 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 uploadFileName = jResp:string_of("uploadFileName")