Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL nRespStatusCode
LOCAL oJson
LOCAL cInvoiceDate
LOCAL cNumber
LOCAL cStatus
LOCAL cStatusDescription
LOCAL cErrorCode
LOCAL cErrorDescription
LOCAL cId
LOCAL cSenderDescription
LOCAL cSenderCountryCode
LOCAL cSenderVatCode
LOCAL cSenderFiscalCode
LOCAL cReceiverDescription
LOCAL cReceiverCountryCode
LOCAL cReceiverVatCode
LOCAL cReceiverFiscalCode
LOCAL cInvoiceType
LOCAL cDocType
LOCAL cFile
LOCAL cFilename
LOCAL cUsername
LOCAL cLastUpdate
LOCAL cCreationDate
LOCAL cIdSdi
LOCAL cPdfFile
LOCAL nPddAvailable
LOCAL i
LOCAL nCount_i

nSuccess := 0

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

oHttp := CreateObject("Chilkat.Http")

//  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.
oHttp:AuthToken := "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
oHttp:SetRequestHeader("Accept", "application/json")

oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://ws.fatturazioneelettronica.aruba.it/services/invoice/out/getByIdSdi?idSdi=11110&includePdf=true", oSbResponseBody)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oSbResponseBody:destroy()
    RETURN
ENDIF

nRespStatusCode := oHttp:LastStatus
? "response status code = " + Str(nRespStatusCode)

oJson := CreateObject("Chilkat.JsonObject")
oJson:LoadSb(oSbResponseBody)
oJson:EmitCompact := 1

? "Response JSON:"
? oJson:Emit()

IF (nRespStatusCode != 200)
    ? "Failed."
    oHttp:destroy()
    oSbResponseBody:destroy()
    oJson:destroy()
    RETURN
ENDIF

//  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
//  }
//  

cErrorCode := oJson:StringOf("errorCode")
cErrorDescription := oJson:StringOf("errorDescription")
cId := oJson:StringOf("id")
cSenderDescription := oJson:StringOf("sender.description")
cSenderCountryCode := oJson:StringOf("sender.countryCode")
cSenderVatCode := oJson:StringOf("sender.vatCode")
cSenderFiscalCode := oJson:StringOf("sender.fiscalCode")
cReceiverDescription := oJson:StringOf("receiver.description")
cReceiverCountryCode := oJson:StringOf("receiver.countryCode")
cReceiverVatCode := oJson:StringOf("receiver.vatCode")
cReceiverFiscalCode := oJson:StringOf("receiver.fiscalCode")
cInvoiceType := oJson:StringOf("invoiceType")
cDocType := oJson:StringOf("docType")
cFile := oJson:StringOf("file")
cFilename := oJson:StringOf("filename")
cUsername := oJson:StringOf("username")
cLastUpdate := oJson:StringOf("lastUpdate")
cCreationDate := oJson:StringOf("creationDate")
cIdSdi := oJson:StringOf("idSdi")
cPdfFile := oJson:StringOf("pdfFile")
nPddAvailable := oJson:BoolOf("pddAvailable")
i := 0
nCount_i := oJson:SizeOfArray("invoices")
DO WHILE i < nCount_i
    oJson:I := i
    cInvoiceDate := oJson:StringOf("invoices[i].invoiceDate")
    cNumber := oJson:StringOf("invoices[i].number")
    cStatus := oJson:StringOf("invoices[i].status")
    cStatusDescription := oJson:StringOf("invoices[i].statusDescription")
    i := i + 1
ENDDO

oHttp:destroy()
oSbResponseBody:destroy()
oJson:destroy()