Sample code for 30+ languages & platforms
Lua Requires Chilkat v11.0.0+

Aruba Fatturazione Elettronica Upload Invoice Signed

See more Aruba Fatturazione Examples

This method must be used by the EO to send an invoice in XML format that has already been digitally signed in accordance with one of these AGID standards:
  • with the extension .p7m and in CAdES-BES format (CMS Advanced Electronic Signatures);
  • with.xml extension and in XAdES-BES format (XML Advanced Electronic Signatures).

Chilkat Lua Downloads

Lua
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/uploadSigned \
--   -H "Accept: application/json" \
--   -H "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" \
--   -H "Content-Type: application/json;charset=UTF-8" \
--   -d '{
--   "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.

-- {
--   "dataFile": "dGVzdA=="
-- }

-- Load the file to be uploaded.
local bdSignedInvoice = chilkat.BinData.new()
local success = bdSignedInvoice:load_file("qa_data/aruba/signedInvoice.xml.p7m")

local json = chilkat.JsonObject.new()
json:update_string("dataFile", bdSignedInvoice:get_encoded("base64"))

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/uploadSigned", 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": "Operazione effettuata - 521e052902be7b879d41e0fd586f0e21",
--   "uploadFileName": "IT01879020517_azdxg.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")