PowerShell 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=="
}'

PowerShell Example

[Reflection.Assembly]::LoadFile("C:\myAssemblies\ChilkatDotNet47.dll")

$rest = New-Object Chilkat.Rest

#  URL: https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password
$bTls = $true
$port = 443
$bAutoReconnect = $true
$success = $rest.Connect("testws.fatturazioneelettronica.aruba.it",$port,$bTls,$bAutoReconnect)
if ($success -ne $true) {
    $("ConnectFailReason: " + $rest.ConnectFailReason)
    $($rest.LastErrorText)
    exit
}

#  See the Online Tool for Generating JSON Creation Code
$json = New-Object Chilkat.JsonObject
$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")

$sbRequestBody = New-Object Chilkat.StringBuilder
$json.EmitSb($sbRequestBody)
$sbResponseBody = New-Object Chilkat.StringBuilder
$success = $rest.FullRequestSb("POST","/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password",$sbRequestBody,$sbResponseBody)
if ($success -ne $true) {
    $($rest.LastErrorText)
    exit
}

$respStatusCode = $rest.ResponseStatusCode
if ($respStatusCode -ge 400) {
    $("Response Status Code = " + $respStatusCode)
    $("Response Header:")
    $($rest.ResponseHeader)
    $("Response Body:")
    $($sbResponseBody.GetAsString())
    exit
}

$jsonResponse = New-Object Chilkat.JsonObject
$jsonResponse.LoadSb($sbResponseBody)

#  See the Online Tool for Generating JSON Parse Code

$errorCode = $jsonResponse.StringOf("errorCode")
$errorDescription = $jsonResponse.StringOf("errorDescription")
$requestID = $jsonResponse.StringOf("requestID")
$i = 0
$count_i = $jsonResponse.SizeOfArray("requestIDList")
while ($i -lt $count_i) {
    $jsonResponse.I = $i
    $fileName = $jsonResponse.StringOf("requestIDList[i].fileName")
    $requestID = $jsonResponse.StringOf("requestIDList[i].requestID")
    $i = $i + 1
}

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"
    }
  ]
}