Android™ Fatturazione Elettronica Aruba IT: Create Transmission Request List

Back to Index

Creazione richiesta di trasmissione “Comunicazioni Finanziarie” in formato zip.

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

CURL Command

curl -X POST  https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password \
-H 'Accept: application/json' \
-H 'Content-Type: application/json;charset=UTF-8' \
-d '{
  "userName" : "Utente",
  "password" : "Password",
  "userID" : "Utente",
  "comunicationType" : "LI",
  "dataFile" : "dGVzdA=="
}'

Android™ Example

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CkRest rest = new CkRest();
    boolean success;

    //  URL: https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password
    boolean bTls = true;
    int port = 443;
    boolean bAutoReconnect = true;
    success = rest.Connect("testws.fatturazioneelettronica.aruba.it",port,bTls,bAutoReconnect);
    if (success != true) {
        Log.i(TAG, "ConnectFailReason: " + String.valueOf(rest.get_ConnectFailReason()));
        Log.i(TAG, rest.lastErrorText());
        return;
        }

    //  See the Online Tool for Generating JSON Creation Code
    CkJsonObject json = new CkJsonObject();
    json.UpdateString("userName","Utente");
    json.UpdateString("password","Password");
    json.UpdateString("userID","Utente");
    json.UpdateString("comunicationType","LI");
    json.UpdateString("dataFile","dGVzdA==");

    rest.AddHeader("Content-Type","application/json;charset=UTF-8");
    rest.AddHeader("Accept","application/json");

    CkStringBuilder sbRequestBody = new CkStringBuilder();
    json.EmitSb(sbRequestBody);
    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = rest.FullRequestSb("POST","/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password",sbRequestBody,sbResponseBody);
    if (success != true) {
        Log.i(TAG, rest.lastErrorText());
        return;
        }

    int respStatusCode = rest.get_ResponseStatusCode();
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
        Log.i(TAG, "Response Header:");
        Log.i(TAG, rest.responseHeader());
        Log.i(TAG, "Response Body:");
        Log.i(TAG, sbResponseBody.getAsString());
        return;
        }

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

    //  See the Online Tool for Generating JSON Parse Code
    String errorCode;
    String errorDescription;
    String requestID;
    int i;
    int count_i;
    String fileName;

    errorCode = jsonResponse.stringOf("errorCode");
    errorDescription = jsonResponse.stringOf("errorDescription");
    requestID = jsonResponse.stringOf("requestID");
    i = 0;
    count_i = jsonResponse.SizeOfArray("requestIDList");
    while (i < count_i) {
        jsonResponse.put_I(i);
        fileName = jsonResponse.stringOf("requestIDList[i].fileName");
        requestID = jsonResponse.stringOf("requestIDList[i].requestID");
        i = i + 1;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Sample JSON Response Body

{
  "errorCode": "",
  "errorDescription": "",
  "requestID": "YWWCED5QWHU7AQGL",
  "requestIDList": [
    {
      "fileName": "ITADFSREETDSD_LI_0001.xml",
      "requestID": "4LMW5CCCBLXKS522"
    },
    {
      "fileName": "ITADFSREETDSD_LI_0002.xml",
      "requestID": "62LXGBLXJCDEAX3M"
    },
    {
      "fileName": "ITADFSREETDSD_LI_0003.xml",
      "requestID": "GBJDXIYJSWMRKQBP"
    }
  ]
}