Sample code for 30+ languages & platforms
Tcl

Aruba Fatturazione Elettronica getByIdSdi

See more Aruba Fatturazione Examples

This method returns the complete status detail of an electronic invoice. Search for a single invoice by SdI identifier.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set http [new_CkHttp]

# Implements the following CURL command:

# curl -X GET https://ws.fatturazioneelettronica.aruba.it/services/invoice/out/getByIdSdi?idSdi=11110&includePdf=true \
#   -H "Accept: application/json" \
#   -H "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="

# Use the following online tool to generate HTTP code from a CURL command
# Convert a cURL Command to HTTP Source Code

# Adds the "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" header.
CkHttp_put_AuthToken $http "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
CkHttp_SetRequestHeader $http "Accept" "application/json"

set sbResponseBody [new_CkStringBuilder]

set success [CkHttp_QuickGetSb $http "https://ws.fatturazioneelettronica.aruba.it/services/invoice/out/getByIdSdi?idSdi=11110&includePdf=true" $sbResponseBody]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    exit
}

set respStatusCode [CkHttp_get_LastStatus $http]
puts "response status code = $respStatusCode"

set json [new_CkJsonObject]

CkJsonObject_LoadSb $json $sbResponseBody
CkJsonObject_put_EmitCompact $json 1

puts "Response JSON:"
puts [CkJsonObject_emit $json]

if {$respStatusCode != 200} then {
    puts "Failed."
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $json
    exit
}

# Sample response:

# Use this online tool to generate parsing code from sample JSON: 
# Generate Parsing Code from JSON

# {
#   "errorCode" : "0000",
#   "errorDescription" : null,
#   "id" : "1",
#   "sender" : {
#     "description" : "Aruba SPA",
#     "countryCode" : "IT",
#     "vatCode" : "22222222",
#     "fiscalCode" : "11111111111"
#   },
#   "receiver" : {
#     "description" : "Aruba SPA",
#     "countryCode" : "IT",
#     "vatCode" : "4444444",
#     "fiscalCode" : "333333333"
#   },
#   "invoiceType" : "FPR12",
#   "docType" : "in",
#   "file" : "dGVzdA==",
#   "filename" : "IT01879020517_jtlk0.xml.p7m",
#   "invoices" : [ {
#     "invoiceDate" : "2021-08-24T12:35:45.363+02:00",
#     "number" : "2021/0001",
#     "status" : "Inviata",
#     "statusDescription" : ""
#   } ],
#   "username" : "Utente",
#   "lastUpdate" : "2021-08-24T10:35:45.363+0000",
#   "creationDate" : "2021-08-24T10:35:45.363+0000",
#   "idSdi" : "11110",
#   "pdfFile" : "ZEdWemRGQmtaZz09",
#   "pddAvailable" : true
# }
# 

set errorCode [CkJsonObject_stringOf $json "errorCode"]
set errorDescription [CkJsonObject_stringOf $json "errorDescription"]
set id [CkJsonObject_stringOf $json "id"]
set senderDescription [CkJsonObject_stringOf $json "sender.description"]
set senderCountryCode [CkJsonObject_stringOf $json "sender.countryCode"]
set senderVatCode [CkJsonObject_stringOf $json "sender.vatCode"]
set senderFiscalCode [CkJsonObject_stringOf $json "sender.fiscalCode"]
set receiverDescription [CkJsonObject_stringOf $json "receiver.description"]
set receiverCountryCode [CkJsonObject_stringOf $json "receiver.countryCode"]
set receiverVatCode [CkJsonObject_stringOf $json "receiver.vatCode"]
set receiverFiscalCode [CkJsonObject_stringOf $json "receiver.fiscalCode"]
set invoiceType [CkJsonObject_stringOf $json "invoiceType"]
set docType [CkJsonObject_stringOf $json "docType"]
set file [CkJsonObject_stringOf $json "file"]
set filename [CkJsonObject_stringOf $json "filename"]
set username [CkJsonObject_stringOf $json "username"]
set lastUpdate [CkJsonObject_stringOf $json "lastUpdate"]
set creationDate [CkJsonObject_stringOf $json "creationDate"]
set idSdi [CkJsonObject_stringOf $json "idSdi"]
set pdfFile [CkJsonObject_stringOf $json "pdfFile"]
set pddAvailable [CkJsonObject_BoolOf $json "pddAvailable"]
set i 0
set count_i [CkJsonObject_SizeOfArray $json "invoices"]
while {$i < $count_i} {
    CkJsonObject_put_I $json $i
    set invoiceDate [CkJsonObject_stringOf $json "invoices[i].invoiceDate"]
    set number [CkJsonObject_stringOf $json "invoices[i].number"]
    set status [CkJsonObject_stringOf $json "invoices[i].status"]
    set statusDescription [CkJsonObject_stringOf $json "invoices[i].statusDescription"]
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $json