Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loHttp
LOCAL loBdSignedInvoice
LOCAL loJson
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcErrorCode
LOCAL lcErrorDescription
LOCAL lcUploadFileName

lnSuccess = 0

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

loHttp = CreateObject('Chilkat.Http')

* 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.
loBdSignedInvoice = CreateObject('Chilkat.BinData')
lnSuccess = loBdSignedInvoice.LoadFile("qa_data/aruba/signedInvoice.xml.p7m")

loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("dataFile",loBdSignedInvoice.GetEncoded("base64"))

loHttp.SetRequestHeader("Accept","application/json")
* Adds the "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" header.
loHttp.AuthToken = "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
loHttp.SetRequestHeader("Content-Type","application/json;charset=UTF-8")

loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpJson("POST","https://ws.fatturazioneelettronica.aruba.it/services/invoice/uploadSigned",loJson,"application/json",loResp)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loBdSignedInvoice
    RELEASE loJson
    RELEASE loResp
    CANCEL
ENDIF

loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loHttp
    RELEASE loBdSignedInvoice
    RELEASE loJson
    RELEASE loResp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

* 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

lcErrorCode = loJResp.StringOf("errorCode")
lcErrorDescription = loJResp.StringOf("errorDescription")
lcUploadFileName = loJResp.StringOf("uploadFileName")

RELEASE loHttp
RELEASE loBdSignedInvoice
RELEASE loJson
RELEASE loResp
RELEASE loSbResponseBody
RELEASE loJResp