Java Fatturazione Elettronica Aruba IT: Get by Invoice ID (Sent)

Back to Index

Ricerca una singola fattura per Id

Documentation: https://fatturazioneelettronica.aruba.it/apidoc/docs.html#_getbyinvoiceid

CURL Command

curl -X GET  https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/{invoiceId} \
-H 'Accept: application/json' \
-H 'Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE='

Java Example

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    CkRest rest = new CkRest();
    boolean success;

    //  URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/{invoiceId}
    boolean bTls = true;
    int port = 443;
    boolean bAutoReconnect = true;
    success = rest.Connect("demows.fatturazioneelettronica.aruba.it",port,bTls,bAutoReconnect);
    if (success != true) {
        System.out.println("ConnectFailReason: " + rest.get_ConnectFailReason());
        System.out.println(rest.lastErrorText());
        return;
        }

    rest.AddHeader("Authorization","Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=");
    rest.AddHeader("Accept","application/json");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = rest.FullRequestNoBodySb("GET","/services/invoice/out/{invoiceId}",sbResponseBody);
    if (success != true) {
        System.out.println(rest.lastErrorText());
        return;
        }

    int respStatusCode = rest.get_ResponseStatusCode();
    if (respStatusCode >= 400) {
        System.out.println("Response Status Code = " + respStatusCode);
        System.out.println("Response Header:");
        System.out.println(rest.responseHeader());
        System.out.println("Response Body:");
        System.out.println(sbResponseBody.getAsString());
        return;
        }

    CkJsonObject jsonResponse = new CkJsonObject();
    jsonResponse.LoadSb(sbResponseBody);

    //  See the Online Tool for Generating JSON Parse Code
    String id;
    String senderDescription;
    String senderCountryCode;
    String senderVatCode;
    String senderFiscalCode;
    String receiverDescription;
    String receiverCountryCode;
    String receiverVatCode;
    String receiverFiscalCode;
    String invoiceType;
    String docType;
    String file;
    String filename;
    String username;
    String lastUpdate;
    String idSdi;
    int i;
    int count_i;
    String invoiceDate;
    String number;
    String status;

    id = jsonResponse.stringOf("id");
    senderDescription = jsonResponse.stringOf("sender.description");
    senderCountryCode = jsonResponse.stringOf("sender.countryCode");
    senderVatCode = jsonResponse.stringOf("sender.vatCode");
    senderFiscalCode = jsonResponse.stringOf("sender.fiscalCode");
    receiverDescription = jsonResponse.stringOf("receiver.description");
    receiverCountryCode = jsonResponse.stringOf("receiver.countryCode");
    receiverVatCode = jsonResponse.stringOf("receiver.vatCode");
    receiverFiscalCode = jsonResponse.stringOf("receiver.fiscalCode");
    invoiceType = jsonResponse.stringOf("invoiceType");
    docType = jsonResponse.stringOf("docType");
    file = jsonResponse.stringOf("file");
    filename = jsonResponse.stringOf("filename");
    username = jsonResponse.stringOf("username");
    lastUpdate = jsonResponse.stringOf("lastUpdate");
    idSdi = jsonResponse.stringOf("idSdi");
    i = 0;
    count_i = jsonResponse.SizeOfArray("invoices");
    while (i < count_i) {
        jsonResponse.put_I(i);
        invoiceDate = jsonResponse.stringOf("invoices[i].invoiceDate");
        number = jsonResponse.stringOf("invoices[i].number");
        status = jsonResponse.stringOf("invoices[i].status");
        i = i+1;
        }
  }
}

Sample JSON Response Body

{
  "id": "1",
  "sender": {
    "description": "Aruba SPA",
    "countryCode": "ITA",
    "vatCode": "6372762541",
    "fiscalCode": "N5Hnt9vvMZ"
  },
  "receiver": {
    "description": "Aruba SPA",
    "countryCode": "ITA",
    "vatCode": "8767263441",
    "fiscalCode": "LVZTeOJ8BN"
  },
  "invoiceType": "FPA12",
  "docType": "in",
  "file": "ZEdWemRBPT0=",
  "filename": "IT07026037883_jtlkl.xml.p7m",
  "invoices": [
    {
      "invoiceDate": "2019-01-21T17:36:21.289+01:00",
      "number": "1",
      "status": "Inviata"
    },
    {
      "invoiceDate": "2019-01-21T17:36:21.289+01:00",
      "number": "2",
      "status": "Consegnata"
    }
  ],
  "username": "Utente",
  "lastUpdate": "2019-01-21T17:36:21.289+01:00",
  "idSdi": null
}